Pro Android with Kotlin


Download 5.42 Mb.
Pdf ko'rish
bet28/223
Sana04.11.2023
Hajmi5.42 Mb.
#1746807
1   ...   24   25   26   27   28   29   30   31   ...   223
Bog'liq
@de android telegram Pro Android with Kotlin Developing Modern Mobile

15
CHAPTER 3: Activities


This is an arbitrary name-value pair in the form android:name="..." android:resource="..." android:value="..." />. 
You can have several of them, and they go into an android.os.Bundle 
element available as PackageItemInfo.metaData.
Caution Writing an app without any activity is possible. The app can still provide services, 
broadcast receivers, and data content as a content provider. One thing you as an app developer 
need to bear in mind is that users do not necessarily understand what such components without 
user interfaces actually do. In most cases, providing a simple main activity just to give information 
is recommended and improves the user experience. In a corporate environment, though, providing 
apps without activities is acceptable.
Starting Activities
Activities can be started in one of two ways. First, if the activity is marked as the launchable 
main activity of an app, the activity can be started from the app launcher. To declare an 
activity as a launchable main activity, inside the AndroidManifest.xml file you’d write the 
following:
"com.example.myapp.ExampleActivity">

"android.intent.action.MAIN" />
"android.intent.category.LAUNCHER" />


android.intent.action.MAIN tells Android that it is the main activity and will go to the 
bottom of a task, and the android.intent.category.LAUNCHER specifies that it must be listed 
inside the launcher.
Second, an activity can be started by an intent from the same app or any other app. For this 
to be possible, inside the manifest you declare an intent filter, as shown here:
"com.example.myapp.ExampleActivity">

"com.example.myapp.ExampleActivity.START_ME" />
"android.intent.category.DEFAULT"/>





Download 5.42 Mb.

Do'stlaringiz bilan baham:
1   ...   24   25   26   27   28   29   30   31   ...   223




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling