How to correctly use the android command line Startup Program

Source: Internet
Author: User
    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

 
 
  1. # 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

 
 
  1. < ?xml version="1.0" encoding="utf-8"?>
  2. < manifest xmlns:android="http://schemas.android.com/apk/res/android"
  3. package="com.android.calculator2">
  4. < application android:label="@string/app_name" android:icon="@drawable/icon">
  5. < activity android:name="Calculator"
  6. android:theme="@android:style/Theme.Black">
  7. < intent-filter>
  8. < action android:name="android.intent.action.MAIN" />
  9. < category android:name="android.intent.category.LAUNCHER" />
  10. < /intent-filter>
  11. < /activity>
  12. < /application>
  13. < /manifest>

The start method of the calculator is as follows:

 
 
  1. # am start -n com.android.calculator2/com.android.calculator2.Calculator

For the example project helloactivity, androidmanifest. XML is as follows:

 
 
  1. < ?xml version="1.0" encoding="utf-8"?>
  2. < manifest xmlns:android="http://schemas.android.com/apk/res/android"
  3. package="com.example.android.helloactivity">
  4. < application android:label="Hello, Activity!">
  5. < activity android:name="HelloActivity">
  6. < intent-filter>
  7. < action android:name="android.intent.action.MAIN"/>
  8. < category android:name="android.intent.category.LAUNCHER"/>
  9. < /intent-filter>
  10. < /activity>
  11. < /application>
  12. < /manifest>

The android Command Line Method for starting the program is as follows:

 
 
  1. # 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:

 
 
  1. # am start -n com.android.calendar/com.android.calendar.LaunchActivity

The startup method of alarmclock is as follows:

 
 
  1. # am start -n com.android.alarmclock/com.android.alarmclock.AlarmClock

The startup methods of music and video are as follows:

 
 
  1. # am start -n com.android.music/com.android.music.MusicBrowserActivity
  2. # am start -n com.android.music/com.android.music.VideoBrowserActivity
  3. # am start -n com.android.music/com.android.music.MediaPlaybackActivity

The android Command Line Method for camera (CAMERA) to start the program is:

 
 
  1. # am start -n com.android.camera/com.android.camera.Camera

The android command line method of browser is as follows:

 
 
  1. # 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 ).

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.