🔧 AI Nachrichten Major AI platforms go down in unprecedented simultaneous outage(03.09.2026 um 17:34 Uhr)
🔧 AI Nachrichten ChatGPT, Claude, and Grok Down? Users Report Widespread Outages(03.09.2026 um 19:14 Uhr)
🔧 AI Nachrichten OpenAI Launches GPT-6 Astra, Says We May Have Entered the AGI Era(03.09.2026 um 22:08 Uhr)
🔧 AI Nachrichten Claude Comes to CarPlay as Fifth Major AI Chatbot App(05.09.2026 um 05:31 Uhr)
🔧 AI Nachrichten OpenAI’s GPT-6 Astra Is AGI, Says NVIDIA CEO Jensen Huang(07.09.2026 um 06:31 Uhr)
🔧 AI Nachrichten Blame AI companies for Mac mini and Mac Studio shortage(31.08.2026 um 10:32 Uhr)
🔧 AI Nachrichten Major AI platforms go down in unprecedented simultaneous outage(03.09.2026 um 17:34 Uhr)
🔧 AI Nachrichten ChatGPT, Claude, and Grok Down? Users Report Widespread Outages(03.09.2026 um 19:14 Uhr)
🔧 AI Nachrichten OpenAI Launches GPT-6 Astra, Says We May Have Entered the AGI Era(03.09.2026 um 22:08 Uhr)
🔧 AI Nachrichten Claude Comes to CarPlay as Fifth Major AI Chatbot App(05.09.2026 um 05:31 Uhr)
🔧 AI Nachrichten OpenAI’s GPT-6 Astra Is AGI, Says NVIDIA CEO Jensen Huang(07.09.2026 um 06:31 Uhr)
🔧 AI Nachrichten Blame AI companies for Mac mini and Mac Studio shortage(31.08.2026 um 10:32 Uhr)
1 Tag Serie
🤖 Android Tipps 🕛 kürzlich 3 Min Lesezeit
0

Introducing Android KTX: Even Sweeter Kotlin Development for Android

↗ Quelle (feedproxy.google.com)
🗣️ Stimme:
📑 Inhaltsübersicht
Posted by Jake Wharton () & James Lau (. We invite you to try it out to give us your feedback and contributions. The other parts of Android KTX that cover the Android Support Library will be available in upcoming Support Library releases.











Let's take a look at some examples of how Android KTX can help you write more natural and concise Kotlin code.



Code Samples Using Android KTX



String to Uri



Let's start with this simple example. Normally, you'd call Uri.parse(uriString). Android KTX adds an extension function to the String class that allows you to convert strings to URIs more naturally.








Kotlin

Kotlin with Android KTX

val uri = Uri.parse(myUriString)

val uri = myUriString.toUri()





Edit SharedPreferences



Editing SharedPreferences is a very common use case. The code using Android KTX is slightly shorter and more natural to read and write.








Kotlin

Kotlin with Android KTX

sharedPreferences.edit()
.putBoolean(key, value)
.apply()

sharedPreferences.edit { 
putBoolean(key, value)
}







Translating path difference



In the code below, we translate the difference between two paths by 100px.








Kotlin

Kotlin with Android KTX

val pathDifference = Path(myPath1).apply {
op(myPath2, Path.Op.DIFFERENCE)
}

val myPaint = Paint()

canvas.apply {
val checkpoint = save()
translate(0F, 100F)
drawPath(pathDifference, myPaint)
restoreToCount(checkpoint)
}



val pathDifference = myPath1 - myPath2

canvas.withTranslation(y = 100F) {
drawPath(pathDifference, myPaint)
}





Action on View onPreDraw



This example triggers an action with a View's onPreDraw callback. Without Android KTX, there is quite a bit of code you need to write.








Kotlin

view.viewTreeObserver.addOnPreDrawListener(
object : ViewTreeObserver.OnPreDrawListener {
override fun onPreDraw(): Boolean {
viewTreeObserver.removeOnPreDrawListener(this)
actionToBeTriggered()
return true
}
})

Kotlin with Android KTX

view.doOnPreDraw { actionToBeTriggered() }




There are many more places where Android KTX can simplify your code. You can read the . When the API has stabilized and we can commit to API compatibility, we plan to release Android KTX as part of the Android Support Library.



We look forward to building Android KTX together with you. Happy Kotlin-ing!







Vollständiger Original-Bericht
Ausführliche Details, Code-Beispiele & Hersteller-Stellungnahme auf feedproxy.google.com.
↗ Original-Artikel auf feedproxy.google.com lesen
Wie bewertest du diesen Beitrag?
1 Klick Feedback
Teilen mit Netzwerk & Team:

Community-Analysen & Experten-Meinungen 0

Verfasse deine eigene Analyse, teile Workarounds oder diskutiere diesen Vorfall im Blog.
Noch keine Community-Analyse verfasst. Markiere einen Textabschnitt oder klicke oben auf Eigene Analyse verfassen“!
Community Pulse: Relevanz-Einschätzung
1 Klick Experten-Votum
🔴 Akute Relevanz 0%
🟡 In Evaluierung 0%
🟢 Keine Auswirkung 0%
Spannende Innovation 0%
Verwandte Story-Cluster & Quellen (Vektor-KI)
Port 8095 Engine
3 Quellen
GPT-6 Astra Release Today? OpenAI’s Next Major AI Model Is Almost Here
1 Quelle
Apple accuses OpenAI of destroying evidence as trade-secrets fight intensifies
1 Quelle
Major AI platforms go down in unprecedented simultaneous outage