Pro Android with Kotlin



Yüklə 4,6 Kb.
Pdf görüntüsü
səhifə35/231
tarix29.11.2023
ölçüsü4,6 Kb.
#138831
1   ...   31   32   33   34   35   36   37   38   ...   231
@de android telegram Pro Android with Kotlin Developing Modern Mobile


part as in 
intent.data 
=
, it might not be sufficient to specify just the scheme/host/port/path inside the 
filter declaration. Under these circumstances, you also have to specify the MIME type, as in 
mimeType="*/*"
. Otherwise, the filter possibly won’t match. This generally happens in a 
content 
provider
environment since the content provider’s 
getType()
method gets called for the 
specified URI and the result gets set as the intent’s MIME type.


22
CHAPTER 3: Activities
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Subject")
emailIntent.putExtra(Intent.EXTRA_TEXT, "Body")
startActivity(Intent.createChooser(
emailIntent, "Send email..."))
// or startActivity(emailIntent) if you want to use
// the standard chooser (or none, if there is only
// one possible receiver).
Caution
It is at the receiving app’s discretion how to exactly handle intent URIs and extra data. A 
poorly designed e-mailer might not allow you to specify e-mail header data at all. To be on the safe 
side, you may want to add all header data in both the 
mailto:
URI 
and
as extra data.
Activities Lifecycle
Activities have a lifecycle, and contrary to traditional desktop applications, they are 
intentionally subject to being killed whenever the Android OS decides to do so. So, you as 
a developer need to take special precautions to make an app stable. More precisely, an 
activity finds itself in one of the following states:
 
Shut down
: The activity is not visible and not processing anything. Still, 
the app containing the activity might be alive because it has some other 
components running.
 
Created
: Either the activity is the main activity and was started by the 
user or some other component or it is an activity regardless of whether 
it is main activity and it was started by some other component, from 
inside the same app or another app if security considerations permit it. 
Also, activity creation happens when you, for example, flip the screen 
and the app needs to be built up with different screen characteristics. 
During the creation process, the callback method 
onCreate()
gets 
called. You must implement this method since there the GUI needs to 
be built up. You can also use this callback method to start or connect to 
services or provide content provider data. And you can use the APIs to 
prepare
playing music, operating the camera, or doing anything else the 
app is made for. This is also a good place to initially set up a database 
or other data storage your app needs.
 
Started
: Once done with the creation (and also in case of a restart after 
a stop), the activity goes into the 
started
state. Here the activity is about 
to become visible to the user. During the start process, the callback 
method 
onStart()
gets called. This is a good place to start broadcast 
receivers, start services, and rebuild internal state and processes you 
quit while the activity went to the stopped state.
 
Resumed
: Shortly before actually becoming visible to the user, the 
activity goes through the resuming process. During that process the 
callback 
onResume()
gets called.
 
Running
: The activity is fully visible, and the user can interact with it. 
This state immediately follows the resuming process.



Yüklə 4,6 Kb.

Dostları ilə paylaş:
1   ...   31   32   33   34   35   36   37   38   ...   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ə