Reaves.dev

v0.1.0

built using

Phoenix v1.7.12

Android

Stephen M. Reaves

::

2023-09-25

Notes about Lesson 6 of CS-6300

Summary

What is Android?

OS for mobile devices

Based on Linux

Powered by Dalkvik VM (for java)

Basic Architecture

GAppsAppsContactsPhoneBrowser...Application FrameworkWindowManagerTelephonyManagerLocationManagerResourceManager...LibrariesSQLiteWebKitSSLOpenGL...RuntimeCore LibrariesDalvik VMLinux Kernel

App Components

Android apps are collections of components of different types:

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

Broadcast Receiver

System/Application event handler

Intents

Abstract description of an operation to be performed

Allows for runtime-binding of decoupled applications

Binding modes:

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>

Android Activity Lifecycle

GalActivity LaunchedoconCreate()al->ocosonStart()oc->osorsonRetart()ors->osoronResume()os->orarActivity Runningor->aroponPause()ar->opAnother activity comes into the fgapkApp Process Killedapk->oc:eUser navigates to the acitivityop->apk:sostonStop()op->ostThe activity is no longer visibleost->orsUser returns to the activityost->apk:sApps with higher priority need memoryodonDestroyost->odThe activity is finished or being destroyed by the systemasdActivity Shut Downod->asd