Android命令行启动程序正确使用技巧解析
2013-03-26 22:33
381 查看
摘自:http://developer.51cto.com/art/201001/180876.htm
Android应用程序的启动方法有许多种,大家可以通过我们以前介绍的快速启动方法来启动,同时还能通过本文介绍的Android命令行启动程序的具体方法来启动程序。在Android中,除了从界面上启动程序之外,还可以从命令行启动程序,使用的是命令行工具am.
Android命令行启动程序的方法为
# am start -n {包(package)名}/{包名}.{活动(activity)名称}
启动的方法可以从每个应用的AndroidManifest.xml的文件中得到,以计算器(calculator)为例,它的
< ?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>
由此计算器(calculator)的启动方法为:
# am start -n com.android.calculator2/com.android.calculator2.Calculator
对于HelloActivity这个示例工程,AndroidManifest.xml如下所示:
< ?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>
由此它的Android命令行启动程序方法为:
# am start -n com.example.android.helloactivity/
com.example.android.helloactivity.HelloActivity
其他的一些应用启动命令,如下所示:
calendar(日历)的启动方法为:
# am start -n com.android.calendar/com.android.calendar.LaunchActivity
AlarmClock(闹钟)的启动方法为:
# am start -n com.android.alarmclock/com.android.alarmclock.AlarmClock
Music 和 Video(音乐和视频)的启动方法为:
# 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命令行启动程序方法为:
# am start -n com.android.camera/com.android.camera.Camera
Browser(浏览器)的Android命令行启动程序方法为:
# am start -n com.android.browser/com.android.browser.BrowserActivity
一般情况希望,一个Android应用对应一个工程。值得注意的是,有一些工程具有多个活动(activity),而有一些应用使用一个工程。例如:在Android界面中,Music和Video是两个应用,但是它们使用的都是packages/apps/Music这一个工程。而在这个工程的AndroidManifest.xml文件中,有包含了不同的活动(activity)。
Android应用程序的启动方法有许多种,大家可以通过我们以前介绍的快速启动方法来启动,同时还能通过本文介绍的Android命令行启动程序的具体方法来启动程序。在Android中,除了从界面上启动程序之外,还可以从命令行启动程序,使用的是命令行工具am.
Android命令行启动程序的方法为
# am start -n {包(package)名}/{包名}.{活动(activity)名称}
启动的方法可以从每个应用的AndroidManifest.xml的文件中得到,以计算器(calculator)为例,它的
< ?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>
由此计算器(calculator)的启动方法为:
# am start -n com.android.calculator2/com.android.calculator2.Calculator
对于HelloActivity这个示例工程,AndroidManifest.xml如下所示:
< ?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>
由此它的Android命令行启动程序方法为:
# am start -n com.example.android.helloactivity/
com.example.android.helloactivity.HelloActivity
其他的一些应用启动命令,如下所示:
calendar(日历)的启动方法为:
# am start -n com.android.calendar/com.android.calendar.LaunchActivity
AlarmClock(闹钟)的启动方法为:
# am start -n com.android.alarmclock/com.android.alarmclock.AlarmClock
Music 和 Video(音乐和视频)的启动方法为:
# 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命令行启动程序方法为:
# am start -n com.android.camera/com.android.camera.Camera
Browser(浏览器)的Android命令行启动程序方法为:
# am start -n com.android.browser/com.android.browser.BrowserActivity
一般情况希望,一个Android应用对应一个工程。值得注意的是,有一些工程具有多个活动(activity),而有一些应用使用一个工程。例如:在Android界面中,Music和Video是两个应用,但是它们使用的都是packages/apps/Music这一个工程。而在这个工程的AndroidManifest.xml文件中,有包含了不同的活动(activity)。
相关文章推荐
- Android命令行启动程序正确使用技巧解析
- Android命令行启动程序正确使用技巧解析
- Android命令行启动程序正确使用技巧解析
- Android中使用am命令实现在命令行启动程序详解
- Android中使用am命令实现在命令行启动程序详解
- Android命令行启动程序-am命令的使用
- Android命令行启动程序-am命令的使用-纠正网上大部分资料的错误
- Android命令行启动程序-am命令的使用
- 程序打包,"错误:应用程序无法启动,因为应用程序的并行配置不正确。有关详细信息,请参阅应用程序事件日志,或使用命令行sxstrace.exe"工具解决办法
- Android命令行启动程序-arm命令的使用
- Android中使用am命令实现在命令行启动程序详解
- Android命令行启动程序-am命令的使用-纠正网上大部分资料的错误
- Android开发片段–命令行安装,卸载,启动,程序(AM,PM)
- Android AM命令行启动程序的方法
- Android -- 使用主题配置文件,去掉程序启动界面的短暂黑屏
- 给使用phonegap的Android程序加上splash screen(启动图片 预览图))
- android 程序强制停止后服务后台启动运行 ---- 不同程序间相助 使用第三方服务
- Android中的XML解析-DOM的使用与开发技巧
- 如何使用命令行启动你的erl 程序
- 使用getopt函数对windows命令行程序进行参数解析