Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the correct skills for using the Android command line launcher

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

Today, I will talk to you about the correct skills of using the Android command line startup program, which may not be well understood by many people. in order to make you understand better, the editor has summarized the following contents for you. I hope you can get something according to this article.

There are many ways to start an Android application, we can start it through the quick start method we introduced before, and we can also start the program through the specific method of the Android command line startup program introduced in this article. In Android, in addition to starting the program from the interface, you can also start the program from the command line, using the command line tool am.

The method to start the program on the Android command line is

# am start-n {package (package) name} / {package name}. {activity (activity) name}

The startup method can be obtained from the AndroidManifest.xml file of each application, taking the calculator (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 startup method of this calculator (calculator) is:

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

For the example project HelloActivity, the 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>

Therefore, its Android command line startup program method is:

# am start-n com.example.android.helloactivity/

Com.example.android.helloactivity.HelloActivity

Some other application startup commands are as follows:

The startup method of calendar (calendar) is:

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

The method to start AlarmClock (alarm clock) is:

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

The startup methods for Music and Video (music and video) are:

# 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 startup program method for Camera (camera) is:

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

The Android command line launcher method for Browser (browser) is:

# am start-n com.android.browser/com.android.browser.BrowserActivity

It is generally expected that an Android application corresponds to a project. It is worth noting that some projects have multiple activities (activity), while some applications use one project. For example, in the Android interface, Music and Video are two applications, but they both use the packages/apps/Music project. In the AndroidManifest.xml file of this project, there are different activities (activity).

After reading the above, do you have any further understanding of the correct techniques for using the Android command line launcher? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report