Pro Android with Kotlin



Yüklə 4,6 Kb.
Pdf görüntüsü
səhifə28/231
tarix29.11.2023
ölçüsü4,6 Kb.
#138831
1   ...   24   25   26   27   28   29   30   31   ...   231
@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"/>





Yüklə 4,6 Kb.

Dostları ilə paylaş:
1   ...   24   25   26   27   28   29   30   31   ...   231




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©genderi.org 2024
rəhbərliyinə müraciət

    Ana səhifə