Skip to content

Android Notes

Android Components

  • Activity - Entry point for user interaction (UI).
  • Service - Entry point for long-running background processes.
  • Broadcast Receiver - Enables the system to deliver events to the app, outside a regular user interaction flow.
  • Content Provider - Manages shared sets of app data that can be stored on the file system.

See - developer.android.com/guide/components/fundamentals

Storage

Application Components

See Also

Application Manifest

The [[https://developer.android.com/guide/topics/manifest/manifest-intro|AndroidManifest.xml]] file configures the Android application.

You can use an Intent to start activities, services, and broadcast receivers.

<?xml version="1.0" encoding="utf-8"?>
<manifest ... >
<application android:icon="@drawable/app_icon.png" ... >
<activity android:name="com.example.project.ExampleActivity"
android:label="@string/example_label" ... >
</activity>
...
</application>
</manifest>

Intent Filter

Uses [[https://developer.android.com/reference/android/content/Intent#ACTION_SEND|Intent#ACTION_SEND]].

<manifest ... >
...
<application ... >
<activity android:name="com.example.project.ComposeEmailActivity">
<intent-filter>
<action android:name="android.intent.action.SEND" />
<data android:type="*/*" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>

Tags

  • <application> element.
    • android:icon attribute points to resources for an icon that identifies the app.
  • <activity> elements for activities.
    • android:name specifies the fully qualified class name of the Activity subclass.
    • android:label specifies a string to use as the user-visible label for the activity.
  • <service> elements for services.
  • <receiver> elements for broadcast receivers.
  • <provider> elements for content providers.
  • <intent-filter> The system identifies the components that can respond to an intent by comparing the intent received.

Features

  • User Permissions.
  • Declares minimum API required.
  • Declares hardware and software used or required.
  • Declares API libraries for linking. (other than the Android.jar)

See Also

Declaring app requirements

build.gradle

Always edit minSdkVersion and targetSdkVersion in the gradle build file not the manifest.

Example - Camera API added in API 26, the minSdkVersion must be equal to or greater than 26 to access the Camera API.

Devices that do not have a camera or have an Android version lower than 8.0 cannot install your app from Google Play.

android {
//...
defaultConfig {
//...
minSdkVersion 26
targetSdkVersion 29
}
}

In the app manifest:

  • name - The qualified name of the feature.
  • required - The API is not actually required to RUN the app, functionality may not be 100%.
<manifest ... >
<uses-feature android:name="android.hardware.camera.any"
android:required="true" />
...
</manifest>

See

Application Resources

  • For every resource that you include in your Android project, the SDK build tools define a unique integer ID, which you can use to reference the resource from your app code or from other resources defined in XML
  • Drawables - res/drawable/ == R.drawable.logo
  • String translation - res/values-fr/

Resource Types

See Also