The android program can be started through the command line in addition to the interface. So let's take a look at the specific operation method of the android command line Startup Program.
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. Taking the calculator as an example, its
- < ?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:
The start method of calendar is as follows:
- # am start -n com.android.calendar/com.android.calendar.LaunchActivity
The startup method of alarmclock is as follows:
- # am start -n com.android.alarmclock/com.android.alarmclock.AlarmClock
The startup methods of music and video are 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
The android Command Line Method for camera (CAMERA) to start the program is:
- # am start -n com.android.camera/com.android.camera.Camera
The android command line method of browser is as follows:
- # 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 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 ).