Introduce yourself – 2 minutes
I have found the concepts here are particularly useful in getting across the core aspects of Android in an incremental way, and will get you developing your first app.
I am hoping that this can eventually become part of a course that encourages younger people to start developing mobile applications for Android.
While I don’t necessarily cover every aspect of Android programming, hopefully people will be more away of the different parts of Android to the point where they can go learn more things themselves
These are 4 main concepts in Android, and they are used in varying degrees in your Android application.
For example, you might never write a content provider, but you should be aware of them.
You should also be aware that just because you can do something, doesn’t mean it’s the only way or even the best way.
The hope is that with these four main ideas as hooks, we can start making sense of all the components in and Android application and how they all join together
The android activity is the most essential component everyone should be aware of.
Most apps have screens that are displayed to the user. When you create an Android app, it creates a default ”Main” activity for you.
There are 3 files we now need to be aware of:
The Activity class – this is the code behind the user interface
The layout file – this is an XML file which we use to construct what the user actually sees on the screen
The Android manifest – this is a application wide controller file. All activities, services, broadcasts, features and permissions must be listed here
The android activity is the most essential component everyone should be aware of.
There are tools to help you design user interfaces!
I feel that we could get our designers to learn this markup and then they would be able to produce the exact interfaces they would like
The manifest is kind of like a “flight controller” of your app. You cannot show an activity that is not here, you may not use a feature that is not listed.
An Intent provides a facility for performing late runtime binding between the code in different applications. Its most significant use is in the launching of activities, where it can be thought of as the glue between activities. It is basically a passive data structure holding an abstract description of an action to be performed.
Intents are how we access most of these new concepts. Intents are used to start services, pass data,
An Intent provides a facility for performing late runtime binding between the code in different applications. Its most significant use is in the launching of activities, where it can be thought of as the glue between activities. It is basically a passive data structure holding an abstract description of an action to be performed.
Intents are how we access most of these new concepts. Intents are used to start services, pass data,
Publisher subscribe model
However, you must be careful not to abuse the opportunity to respond to broadcasts and run jobs in the background that can contribute to a slow system performance,
Provide database-style access to apps on the same device
Do not be afraid of the diagram!
Essentially as a “good citizen” you can have access to certain things on an Android device, like contacts, and read that information using standard database methods.
it continues to run in the background even if the user switches to another applicationA foreground service performs some operation that is noticeable to the user. For example, an audio app would use a foreground service to play an audio track. Foreground services must display a notification. Foreground services continue running even when the user isn't interacting with the app.
A background service performs an operation that isn't directly noticed by the user. For example, if an app used a service to compact its storage, that would usually be a background service.
A bound service offers a client-server interface that allows components to interact with the service, send requests, receive results, and even do so across processes with inter-process communication (IPC). A bound service runs only as long as another application component is bound to it. Multiple components can bind to the service at once, but when all of them unbind, the service is destroyed.Caution: A service runs in the main thread of its hosting process; the service does not create its own thread and does not run in a separate process unless you specify otherwise. If your service is going to perform any CPU-intensive work or blocking operations, such as MP3 playback or networking, you should create a new thread within the service to complete that work. By using a separate thread, you can reduce the risk of Application Not Responding (ANR) errors, and the application's main thread can remain dedicated to user interaction with your activities.
The IntentService class provides a straightforward structure for running an operation on a single background thread. This allows it to handle long-running operations without affecting your user interface's responsiveness. Also, an IntentService isn't affected by most user interface lifecycle events, so it continues to run in circumstances that would shut down an AsyncTask
An IntentService has a few limitations:
1. It can't interact directly with your user interface. To put its results in the UI, you have to send them to an Activity.
2. Work requests run sequentially. If an operation is running in an IntentService, and you send it another request, the request waits until the first operation is finished.
3. An operation running on an IntentService can't be interrupted.