如何运行(不只是安装)使用的.apk文件Android应用程序? [英] How to run (not only install) an android application using .apk file?
问题描述
是否有关于 CMD.EXE
的任何命令,让我使用 .apk文件启动特定的Android应用程序的主要活动code>该应用程序的文件。请注意,我知道这个命令只安装Android应用程序:
Is there any command on cmd.exe
that would allow me to start the main activity of a particular android application using the .apk
file of that application. Please note that I know this command which only installs an android application:
adb install myapp.apk
此命令将只安装的myapp </ code>在仿真器上,我要(通过其图标进行单一的点击)手动运行模拟器这个应用程序。
This command will only install myapp
onto the emulator and I have to manually run this application from the emulator (by performing single click on its icon).
我想要做的是使用它不仅安装应用程序的命令,而且开始其主要活动(请注意,我只有它的 .apk文件
文件,所以我不知道是什么包名称或任何活动的名字是)。
What I want to do is use a command which not only installs the application but also starts its main activity (please note that I have only its .apk
file so I don't know what the package name or any activity name is).
推荐答案
您不能安装,并一气呵成运行 - 但你肯定可以使用adb来启动已安装的应用程序。使用adb外壳分开始火的意图 - 你需要使用正确的意图为您的应用虽然。下面是一些例子:
You can't install and run in one go - but you can certainly use adb to start your already installed application. Use adb shell am start to fire an intent - you will need to use the correct intent for your application though. A couple of examples:
adb shell am start -a android.intent.action.MAIN -n com.android.settings/.Settings
将启动设置,以及
will launch Settings, and
adb shell am start -a android.intent.action.MAIN -n com.android.browser/.BrowserActivity
将推出浏览器。 如果你想在某个特定页面,点浏览器,这样做
will launch the Browser. If you want to point the Browser at a particular page, do this
adb shell am start -a android.intent.action.VIEW -n com.android.browser/.BrowserActivity http://www.google.co.uk
如果您不知道在APK活动的名称,然后做到这一点
If you don't know the name of the activities in the APK, then do this
aapt d xmltree <path to apk> AndroidManifest.xml
输出内容将包括这样的内容:
the output content will includes a section like this:
E: activity (line=32)
A: android:theme(0x01010000)=@0x7f080000
A: android:label(0x01010001)=@0x7f070000
A: android:name(0x01010003)="com.anonymous.MainWindow"
A: android:launchMode(0x0101001d)=(type 0x10)0x3
A: android:screenOrientation(0x0101001e)=(type 0x10)0x1
A: android:configChanges(0x0101001f)=(type 0x11)0x80
E: intent-filter (line=33)
E: action (line=34)
A: android:name(0x01010003)="android.intent.action.MAIN"
XE: (line=34)
这是告诉你的主要活动(主窗口)的名称,而且您现在可以运行
That tells you the name of the main activity (MainWindow), and you can now run
adb shell am start -a android.intent.action.MAIN -n com.anonymous/.MainWindow
这篇关于如何运行(不只是安装)使用的.apk文件Android应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!