Android
Summary
What is Android?
OS for mobile devices
Based on Linux
Powered by Dalkvik VM (for java)
Basic Architecture
App Components
Android apps are collections of components of different types:
- Activity
- Service
- Content Provider
- Broadcast Receiver
All four are connected by intents
and tied together by the manifest
Activity
Single screen with a UI
Independent units that work together to form a cohesive whole
Can be invoked by other applications
Service
App component that performs a (usually) long-running operation in the background.
Like music playing service or download service
Content Providers
Provides structured interface to a set of data.
SQLite content provider gives basic CRUD
Content providers can also be used to share data with other applications
- Like Address Book
Broadcast Receiver
System/Application event handler
Intents
Abstract description of an operation to be performed
- Action
- Data
Allows for runtime-binding of decoupled applications
Binding modes:
- Direct (Activity)
- Direct (Service)
- Broadcast
Manifests
Keeps android app together
XML file that declares components of app
<!-- @REF [Example android manifest](https://developer.android.com/guide/topics/manifest/manifest-intro)-->
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
android:versionCode="1"
android:versionName="1.0">
<!-- Beware that these values are overridden by the build.gradle file -->
<uses-sdk android:minSdkVersion="15" android:targetSdkVersion="26" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<!-- This name is resolved to com.example.myapp.MainActivity
based on the namespace property in the build.gradle file -->
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".DisplayMessageActivity"
android:parentActivityName=".MainActivity" />
</application>
</manifest>
Simplified
<?xml version="1.0" encoding="utf-8"?>
<manifest>
<uses-sdk ... />
<uses-feature ... />
<uses-permission ... />
<application>
<activity />
<service />
<provider />
<receiver />
</application>
</manifest>