There are many ways to start Android applications. You can start them using the Quick Start method we introduced earlier, in addition, you can use the Android command line to start the program. In Android, in addition to starting a program from the interface, you can also start the program from the command line, using the command line tool am.
The Android Command Line Method for starting a program is
- # Am start-n {package name}/{package name}. {activity name}
The startup method can be obtained from the AndroidManifest. xml file of each application. Take the calculator as an example.
- < ?xml version="1.0" encoding="utf-8"?>
- < manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.android.calculator2">
- < application android:label="@string/app_name"
android:icon="@drawable/icon">
- < activity android:name="Calculator"
- android:theme="@android:style/Theme.Black">
- < intent-filter>
- < action android:name="android.intent.action.MAIN" />
- < category android:name="android.intent.category.LAUNCHER" />
- < /intent-filter>
- < /activity>
- < /application>
- < /manifest>
The start method of the calculator is as follows:
- # am start -n com.android.calculator2/com.android.calculator2.Calculator
For the example project HelloActivity, AndroidManifest. xml is as follows:
- < ?xml version="1.0" encoding="utf-8"?>
- < manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.example.android.helloactivity">
- < application android:label="Hello, Activity!">
- < activity android:name="HelloActivity">
- < intent-filter>
- < action android:name="android.intent.action.MAIN"/>
- < category android:name="android.intent.category.LAUNCHER"/>
- < /intent-filter>
- < /activity>
- < /application>
- < /manifest>
The Android Command Line Method for starting the program is as follows:
- # am start -n com.example.android.helloactivity/
com.example.android.helloactivity.HelloActivity
Other application startup commands are as follows:
Use the following method to start a calendar:
- # am start -n com.android.calendar/com.android.calendar.LaunchActivity
The startup method of the AlarmClock alarm is as follows:
- # am start -n com.android.alarmclock/com.android.alarmclock.AlarmClock
The startup method of Music and Video is as follows:
- # am start -n com.android.music/com.android.music.MusicBrowserActivity
- # am start -n com.android.music/com.android.music.VideoBrowserActivity
- # am start -n com.android.music/com.android.music.MediaPlaybackActivity
Camera) Android command line to start the program method:
- # am start -n com.android.camera/com.android.camera.Camera
Browser) Android command line to start the program:
- # am start -n com.android.browser/com.android.browser.BrowserActivity
Generally, an Android Application corresponds to a project. It is worth noting that some projects have multiple activity activities), while some applications use one project. For example, in the Android interface, Music and Video are two applications, but they all use the packages/apps/Music project. The AndroidManifest. xml file of this project contains different activities ).