Ist es möglich, eine tatsächliche Android-Anwendung über die Befehlszeile in Android zu starten? Angenommen, ich möchte einfach meinen Kalender starten/in den Vordergrund bringen. Gibt es eine Möglichkeit, wie ich das machen kann:
startapp com.google.calendar
Mit adb glaube ich, dass es möglich ist:
am [start|instrument]
am start [-a <action>] [-d ] [-t <mime_type>]
[-c <category> [-c <category>] ...]
[-e <extra_key> <extra_value> [-e <extra_key> <extra_value> ...]
[-n <component>] [-D] [<uri>]
am instrument [-e <arg_name> <arg_value>] [-p <prof_file>]
[-w] <component>
Zum Beispiel haben wir ein Android-Programm mit Manifest wie folgt:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.app1.android.xtract">
<application android:icon="@drawable/icon">
<activity class=".Contact" android:label="@string/app_name">
<intent-filter>
<action android:value="android.intent.action.MAIN" />
<category android:value="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
.
.
</manifest>
So führen Sie den Codeausgabebefehl wie folgt aus (in einer Zeile):
am start -a android.intent.action.MAIN -n com.app1.android.xtract/com.app1.android.xtract.Contact
Alle Apps haben unterschiedliche Aktivitäten. Es gibt eine App namens QuickShortcutMaker , die Ihnen hilft, wenn Sie nicht mit dem Dekompilieren von Apps beginnen möchten, um ihre Manifestdateien anzuzeigen. Denken Sie jedoch, dass Sie root sein müssen, um Apps über das Terminal zu öffnen.
# Examples
# From terminal emulator or adb as root open settings
am start com.android.settings/.Settings
# From ssh as root open settings
adb shell am start com.android.settings/.Settings
#Function to download a given url with chrome or stock browser
downloadurl(){ if [ $(pm list packages | grep -e 'com.android.chrome') ]; then am start -n com.android.chrome/com.google.android.apps.chrome.Main -d $1; sleep 10; input keyevent 4; return; fi; if [ $(pm list packages | grep -e 'com.android.browser') ]; then am start -a android.intent.action.VIEW -n com.android.browser/.BrowserActivity -d $1 && sleep 5; input keyevent 4; return; fi; am start -a android.intent.action.VIEW -d $1 && sleep 10; input keyevent 4; }
downloadurl "http://your.site.file.example.zip"
Naftuli Kay
adb
also gebe ich dir das :)