|
Pro Android with Kotlin@de android telegram Pro Android with Kotlin Developing Modern Mobile8
CHAPTER 2: Application
a component can be removed because it is no longer needed or that it must be removed
because of a device resource shortage.
To make your app or component run as stable as possible and give your users a good
feeling about its reliability, a deeper knowledge of the lifecycle of Android components is
helpful. We will be looking at system characteristics of components and their lifecycles in
this chapter.
Simple apps and Android components are easy to build; just refer to one of the tutorials on
the official Android web site or one of the thousand other tutorials elsewhere on the Web.
A simple app is not necessarily a professional-level stable app, though, because Android
state handling as far as the app is concerned is not the same as for a desktop application.
The reason for this is that your Android device might decide to kill your app to save system
resources, especially when you temporarily suspend the app in question because you use
one or more other apps for some time.
Of course, Android will most likely never kill apps you are currently working with, but you
have to take precautions. Any app that was killed by Android can be restarted in a defined
data and processing state, including most currently entered data by the user and possibly
interfering in the least possible amount with the user’s current workflow.
From a file perspective, an Android app is a single zip archive file with the suffix
.apk
.
It contains your complete app including all meta-information, which is necessary to run the app
on an Android device. The most important control artifact inside is the file
AndroidManifest.xml
describing the application and the components an application consists of.
We do not in detail cover this archive file structure here, since in most cases Android Studio
will be taking care of creating the archive correctly for you, so you usually don’t need to
know about its intrinsic functioning. But you can easily look inside. Just open any
*.apk
file;
for example, take a sample app you’ve already built using Android Studio, as shown here:
AndroidStudioProject/[YOUR-APP]/release/app-release.apk
Figure 2-2.
An APK file unzipped
Then unzip it. APK files are just normal zip files. You might have to temporarily change the
suffix to
.zip
so your unzip program can recognize it. Figure
2-2
shows an example of an
unzipped APK file.
|
|
|