【问题标题】:How to launch an Android application from the terminal emulator如何从终端模拟器启动 Android 应用程序
【发布时间】:2016-01-30 09:41:27
【问题描述】:

我正在尝试从 Android 终端模拟器启动应用程序,但我似乎无法获取命令的语法或上下文。

am start -n 

这就是我所拥有的。

应用保存在/data/app文件夹中

应用数据存储在/data/data文件夹中

这是我尝试过的。

am start -n /data/app/com.hcg.cok.gp-1.apk/ com.hcg.com.gp/ com.clash.of.kings.EmpireActivity

我知道这是语法错误或上下文错误,有人能告诉我我做错了什么吗?这是我从 shell 得到的错误。

u0_a250@trltetmo:/$ su om.hcg.cok.gp-1.apk /.com.clash.of.kings.EmpireActivity

我已经尝试了我能想到的一切来更改我输入的内容,因此我遇到了其他错误。以下是我尝试过的所有不同方法。

    am start -n /data/data/com.hcg.cok.gp/ ./data/app/com.hcg.cok.gp/ .com/clash.of.kings.EmpireActivity
    am start -n /data/app/com.hcg.cok.gp-1.apk/ .EmpireActivity
    am start -n /data/app/com.hcg.cok.gp-1.apk/ ./data/data/com.hcg.cok.gp/ .com.clash.of.kings.EmpireActivity

我已经尝试了所有我能想到的方法,我有什么问题?我需要从 shell 启动这个游戏,以便我可以将输入点击命令传递给它,而不会被收入文本、电子邮件或任何其他会强制应用程序进入后台并破坏我的输入流到游戏的事件打断它们,我正在 tasker 中构建它,只要我的手机没有其他事情可以做我从 shell 输入的命令就可以完美地工作,但是如果系统中发生任何其他事情,它会将游戏推入后台并在它返回到前台 shell 现在已经模拟了水龙头,但是对于在游戏前面被放到前台 d 的应用程序,它破坏了我正在尝试做的事情,所以我的想法是我是否可以从 shell 启动游戏,并且在同一个shell中传递我的输入命令,如果游戏被强制进入后台并不重要,因为它在我的输入命令也在运行的shell中运行。对于某些代码中的错误,抱歉,在我的终端中是正确的,但我的手机不喜欢论坛并不断删除字母或更改它们的大小写。我不在电脑附近,因此无法轻松修复这些错误。

这是整个清单,我有正确的包和活动,是否有可能因为我没有设置 shell 的 UID 而没有启动?清单中有一行谈到检查用户

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:"http://schemas.android.com/apk/res/android"         android:versionCode="708" android:versionName="1.1.10" android:installLocation="preferExternal" package="com.hcg.cok.gp" platformBuildVersionCode="22" platformBuildVersionName="5.1-1756733">
<supports-screens android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" android:xlargeScreens="true" />
<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="22" />
<uses-permission android:name="com.android.vending.BILLING" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_DEVICE_STATS" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
<uses-permission android:name="android.permission.GET_TASKS" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<permission android:name="com.hcg.cok.gp.permission.C2D_MESSAGE" android:protectionLevel="signature|signatureOrSystem" />
<uses-permission android:name="com.hcg.cok.gp.permission.C2D_MESSAGE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<application android:label="@string/app_name" android:icon="@drawable/cok_icon" android:name="com.clash.of.kings.EmpireApplication" android:debuggable="false" android:largeHeap="true">
    <meta-data android:name="com.google.android.gms.games.APP_ID" android:value="@string/app_id" />
    <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
    <activity android:theme="@style/MyTheme" android:label="@string/app_name" android:name="com.clash.of.kings.EmpireActivity" android:launchMode="standard" android:screenOrientation="portrait" android:configChanges="keyboardHidden|orientation">
        <meta-data android:name="XINGCLOUD_CHANNEL" android:value="market" />
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
        <intent-filter>
            <action android:name="org.hcg.stac.empire.intent.action.IF" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
            <data android:scheme="cok" />
        </intent-filter>
        <meta-data android:name="io.branch.sdk.BranchKey" android:value="key_live_knjHdkLtLaoWWChZ9ZmCIgipAAnT53Wn" />
        <intent-filter>
            <data android:scheme="cokBranch" android:host="open" />
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
        </intent-filter>
    </activity>
    <meta-data android:name="com.facebook.sdk.ApplicationName" android:value="@string/app_name" />
    <activity android:theme="@*android:style/Theme.Translucent.NoTitleBar" android:label="@string/app_name" android:name="com.facebook.FacebookActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize" />
    <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/fb_app_id" />
    <provider android:name="com.facebook.FacebookContentProvider" android:exported="true" android:authorities="com.facebook.app.FacebookContentProvider713457855362204" />
    <meta-data android:name="AdjustAppToken" android:value="cbc4rfy5xrad" />
    <meta-data android:name="AdjustLogLevel" android:value="info" />
    <meta-data android:name="AdjustEnvironment" android:value="production" />
    <meta-data android:name="AdjustEventBuffering" android:value="true" />
    <receiver android:name="com.appsflyer.AppsFlyerLib" android:exported="true">
        <intent-filter>
            <action android:name="com.android.vending.INSTALL_REFERRER" />
        </intent-filter>
    </receiver>
    <receiver android:name="it.partytrack.sdk.ReferrerReceiver" android:exported="true">
        <intent-filter>
            <action android:name="com.android.vending.INSTALL_REFERRER" />
        </intent-filter>
    </receiver>
    <receiver android:name="com.adjust.sdk.ReferrerReceiver" android:exported="true">
        <intent-filter>
            <action android:name="com.android.vending.INSTALL_REFERRER" />
        </intent-filter>
    </receiver>
    <receiver android:name="com.google.ads.conversiontracking.InstallReceiver" android:exported="true">
        <intent-filter>
            <action android:name="com.android.vending.INSTALL_REFERRER" />
        </intent-filter>
    </receiver>
    <receiver android:name="com.clash.of.kings.COKInstallReceiver" android:exported="true">
        <intent-filter>
            <action android:name="com.android.vending.INSTALL_REFERRER" />
        </intent-filter>
    </receiver>
    <receiver android:name="com.inmobi.commons.analytics.androidsdk.IMAdTrackerReceiver" android:enabled="true" android:exported="true">
        <intent-filter>
            <action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
            <action android:name="com.inmobi.share.id" />
        </intent-filter>
    </receiver>
    <activity android:theme="@*android:style/Theme.Translucent.NoTitleBar" android:name="com.inmobi.androidsdk.IMBrowserActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenSize|smallestScreenSize" android:hardwareAccelerated="true" />
    <service android:name="org.hcg.notifies.LocalNotificationIntentService" />
    <receiver android:name="org.hcg.notifies.LocalBroadcastReceiver" />
    <receiver android:name="org.hcg.stac.empire.common.manager.NotificationReceiver" android:process=":remote">
        <intent-filter>
            <action android:name="com.hcg.cok.intent.action.NOTIFICATION" />
            <action android:name="com.hcg.cok.intent.action.FREE_LOTTERY" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </receiver>
    <service android:name="com.google.analytics.tracking.android.CampaignTrackingService" />
    <meta-data android:name="UMENG_APPKEY" android:value="526f648856240b025f008fff" />
    <meta-data android:name="UMENG_CHANNEL" android:value="android_marekt_global" />
    <meta-data android:name="TESTIN_APPKEY" android:value="ed64e49e02a4441326ac32a2598cf0af" />
    <meta-data android:name="TESTIN_CHANNEL" android:value="android_marekt_global" />
    <meta-data android:name="com.parse.push.gcm_sender_id" android:value="id:312229299745" />
    <receiver android:name="com.parse.GcmBroadcastReceiver" android:permission="com.google.android.c2dm.permission.SEND">
        <intent-filter>
            <action android:name="com.google.android.c2dm.intent.RECEIVE" />
            <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
            <category android:name="com.hcg.cok.gp" />
        </intent-filter>
    </receiver>
    <receiver android:name="com.google.android.gcm.GCMBroadcastReceiver" android:permission="com.google.android.c2dm.permission.SEND">
        <intent-filter>
            <action android:name="com.google.android.c2dm.intent.RECEIVE" />
            <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
            <category android:name="com.hcg.cok.gp" />
        </intent-filter>
    </receiver>
    <service android:name="org.hcg.stac.empire.common.manager.GCMIntentService" />
    <activity android:name="com.umeng.api.activity.OauthActivity" android:screenOrientation="unspecified" android:configChanges="keyboardHidden|orientation" android:windowSoftInputMode="10" />
    <activity android:theme="@style/Theme_IOSched" android:name="com.umeng.api.activity.UpdateStatusActivity" android:screenOrientation="unspecified" android:configChanges="keyboardHidden|orientation" android:windowSoftInputMode="14" />
    <activity android:name="com.tapjoy.TJCOffersWebView" android:configChanges="keyboardHidden|orientation" />
    <activity android:name="com.tapjoy.TapjoyFeaturedAppWebView" android:configChanges="keyboardHidden|orientation" />
    <activity android:name="com.tapjoy.TapjoyVideoView" android:configChanges="keyboardHidden|orientation" />
    <activity android:name="com.sponsorpay.sdk.android.publisher.OfferWallActivity" android:configChanges="orientation" />
    <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
    <service android:name="com.parse.PushService" />
    <receiver android:name="com.parse.ParseBroadcastReceiver">
        <intent-filter>
            <action android:name="android.intent.action.BOOT_COMPLETED" />
            <action android:name="android.intent.action.USER_PRESENT" />
        </intent-filter>
    </receiver>
    <receiver android:name="com.parse.ParsePushBroadcastReceiver" android:exported="false">
        <intent-filter>
            <action android:name="com.parse.push.intent.RECEIVE" />
            <action android:name="com.parse.push.intent.DELETE" />
            <action android:name="com.parse.push.intent.OPEN" />
        </intent-filter>
    </receiver>
    <receiver android:name="com.clash.of.notifies.HFParseCustomReceiver" android:exported="false">
        <intent-filter>
            <action android:name="com.hcg.cok.gp.UPDATE_STATUS" />
        </intent-filter>
    </receiver>
    <activity android:theme="@style/Helpshift_Theme_Activity" android:label="@string/hs__conversation_header" android:name="com.helpshift.HSConversation" android:configChanges="locale|orientation|screenSize|layoutDirection" />
    <activity android:theme="@style/Helpshift_Theme_Activity" android:name="com.helpshift.HSQuestionsList" android:configChanges="orientation|screenSize" />
    <activity android:theme="@style/Helpshift_Theme_Activity" android:label="@string/hs__question_header" android:name="com.helpshift.HSQuestion" android:configChanges="orientation|screenSize" android:hardwareAccelerated="true" />
    <activity android:theme="@style/Helpshift_Theme_Activity" android:name="com.helpshift.HSSection" android:configChanges="orientation|screenSize" android:windowSoftInputMode="20" android:hardwareAccelerated="true" />
    <activity android:theme="@style/Helpshift_Theme_Activity" android:label="@string/hs__help_header" android:name="com.helpshift.HSFaqs" android:configChanges="orientation|screenSize" android:windowSoftInputMode="20" android:hardwareAccelerated="true" />
    <activity android:theme="@style/Helpshift_Theme_Dialog" android:name="com.helpshift.HSReview" android:configChanges="orientation|screenSize" />
    <activity android:theme="@style/Helpshift_Theme_Activity" android:name="com.helpshift.ScreenshotPreviewActivity" android:configChanges="orientation|screenSize" />
    <activity android:theme="@style/Helpshift_Theme_Activity" android:name="com.helpshift.SearchResultActivity" android:configChanges="orientation|screenSize" />
    <service android:label="Helpshift Service" android:name="com.helpshift.HSService" />
    <service android:label="Helpshift Service" android:name="com.helpshift.HSRetryService" />
    <meta-data android:name="com.vk.sdk.AppId" android:value="5024256" />
    <activity android:name="com.vk.sdk.VKOpenAuthActivity" />
    <activity android:theme="@style/VK_Transparent" android:label="ServiceActivity" android:name="com.vk.sdk.VKServiceActivity" />
    <activity android:theme="@style/Activity_Theme" android:name="com.elex.chatservice.view.ChatActivity" android:screenOrientation="portrait" android:configChanges="locale|orientation|screenSize" />
    <activity android:theme="@style/Activity_Theme" android:name="com.elex.chatservice.view.ChannelListActivity" android:screenOrientation="portrait" android:configChanges="locale|orientation|screenSize" />
    <activity android:theme="@style/Activity_Theme" android:name="com.elex.chatservice.view.ForumActivity" android:screenOrientation="portrait" android:configChanges="locale|orientation|screenSize" />
    <activity android:theme="@style/Activity_Theme" android:name="com.elex.chatservice.view.MemberSelectorActivity" android:screenOrientation="portrait" android:configChanges="locale|orientation|screenSize" />
    <activity android:theme="@style/Activity_Theme" android:name="com.elex.chatservice.view.WriteMailActivity" android:screenOrientation="portrait" android:configChanges="locale|orientation|screenSize" />
    <meta-data android:name="io.fabric.ApiKey" android:value="a9561a0f09e88d758810060aea57aac008e89d0c" />
    <meta-data android:name="io.branch.sdk.BranchKey" android:value="key_live_knjHdkLtLaoWWChZ9ZmCIgipAAnT53Wn" />
</application>

【问题讨论】:

  • 您尝试启动的应用程序是否已安装? (你说在data/app文件夹下,是什么意思?)
  • 是的,该应用程序已经安装,我猜不是将它安装在 app/asec 文件夹中,也不是使用 app/app-private 文件夹,开发人员选择加载 /data 中的所有库和资源文件夹/data/com.hcg.cok.gp 而应用程序包 (apk) 自身加载到 data/app/com.hcg.cok.gp-1.apk 文件夹中

标签: android shell android-intent


【解决方案1】:

am start -n com.package.name/.ActivityName

【讨论】:

  • 嗨,5c0tt,欢迎。请考虑添加更多信息。
【解决方案2】:

根据您的命令,我认为您正在安装应用程序并在一个命令中启动两者?

如果是,那是不可能的。 您必须使用一个命令进行安装 -

adb install package.name

并运行您的活动 -

adb shell am start -n com.package.name/com.package.name.ActivityName

你的包名出现在哪里 - com.hcg.cok.gp

您的活动名称出现在哪里 - com.clash.of.kings.EmpireActivity

Reference

【讨论】:

  • 好的,这就是我搞砸的地方,不,我不想安装并启动它,它已经安装了我只需要启动它,所以如果我准备好了,我需要这个.
  • 上午开始 -n /data/data/com.hcg.cok.gp/com.hcg.cok.gp.clash.of.kings.EmpireActivity。
  • 如果我需要完整的 com.clash.of.kings.EmpireActivity,您的示例在哪里说 .ActivityName 我错过了这条船吗?因为我仍然收到与输入相同的错误。我开始 -n /data/app/com.hcg.cok.gp-1.apk/com.hcg.cok.gp.com.clash.of.kings.EmpireActivity。
  • 我怀疑你的包名也包含'.apk'/
  • 我得到了同样的错误。我开始 -n com.hcg.cok.gp/com.hcg.cok.gp.com.clash.of.kings.EmpireActivity。这可能不适用于不可调试的应用程序吗?
【解决方案3】:

您可以通过 adb 使用 am start 命令。漂浮在互联网上的浏览器应用示例:

am start -a android.intent.action.MAIN -n com.android.browser/.BrowserActivity 

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-05-14
    • 1970-01-01
    • 2011-04-26
    • 2022-06-15
    相关资源
    最近更新 更多