Pro Android with Kotlin
Figure 8-9. A preferences screen 190
Download 5.42 Mb. Pdf ko'rish
|
@de android telegram Pro Android with Kotlin Developing Modern Mobile
Figure 8-9. A preferences screen
190 CHAPTER 8: APIs You can instead have the entries open a preferences subscreen. For this aim, again in preferences.xml you write the following: "http://schemas.android.com/apk/res/android"> ... android:title="Subscreen Title" android:persistent="false"> android:summary="A Switch" android:title="A Switch" /> android:summary="A Ringtone" android:title="A Ringtone" /> ... Advanced preferences features include a standardized header-contents way of presenting preferences, overwriting the setting item UIs, creating your own preferences UI, and tweaking the preferences data location. For details, refer to the online documentation of the Settings API. 191 © Peter Späth 2018 P. Späth, Pro Android with Kotlin, https://doi.org/10.1007/978-1-4842-3820-2_9 Chapter 9 User Interface The user interface is certainly the most important part of any end-user app. For corporate usage, apps without user interfaces are possible, but even then in most cases you will have some kind of rudimentary UI, if for no other reason just to avoid the Android OS killing your app too readily during resource housekeeping tasks. In this chapter, we will not cover the basics of UI development for Android. Instead, it is expected that you’ve read some introductory-level book or worked through the official tutorials (or any number of the other tutorials you will find on the Web). What we do here is to cover a couple of important UI-related issues that help you to create more stable apps or apps with special outstanding requirements. Background Tasks Android relies on a single-threaded execution model. This means when an app starts, it by default starts only a single thread, called the main thread, in which all actions run unless you explicitly use background threads for certain tasks. This automatically means you have to take special precautions if you have long-running tasks that would interrupt a fluent UI workflow. It is not acceptable for modern apps to have the UI freeze after the user taps a button or because this action leads to a process running for a few seconds or longer. It is therefore vital to put long-running tasks into the background. One way to accomplish putting things into the background is to use IntentService objects, as described in Chapter 4 . Depending on the circumstances, it might, however, blow up your app design to put all background work into services; in addition, having too many services run on a device will not help keep resources usage low. Another option is to use loaders as described in Chapter 8 . For low-level tasks, however, it is better to use a more low-level approach. You have several options here, which we describe in the following sections. |
Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling
ma'muriyatiga murojaat qiling