英文:
Can not start activity from command line in Android 13
问题
无法通过以下命令从终端打开活动:
adb shell am start -n com.mypackage/com.mypackage.MyActivity -d --es myvariable1 myvalue1 --es myvariable2 myvalue2 -d
在Android 13上返回:
> Starting: Intent { act=android.intent.action.MAIN
> cat=[android.intent.category.LAUNCHER] dat= pkg=username
> cmp=com.mypackage/.MyActivity } Error type 3 Error:
> Activity class {com.mypackage/com.mypackage.MyActivity} does not
> exist.
在Android 12及更低版本上有效。
在链接https://developer.android.com/about/versions/13/behavior-changes-all#intents中找不到有关此问题的任何信息。
当我按照链接中提到的Intent过滤器匹配时
adb shell am start -a android.intent.action.VIEW -d myscheme://myhost/myprefix -n com.mypackage/com.mypackage.MyActivity
可以打开,但我需要在没有myscheme://myhost/myprefix和View intent的情况下打开活动。
你有什么想法?
英文:
I cannot open activity from the terminal via the command below,
adb shell am start -n com.mypackage/com.mypackage.MyActivity -d --es myvariable1 myvalue1 --es myvariable2 myvalue2 -d
On Android 13 it returns:
> Starting: Intent { act=android.intent.action.MAIN
> cat=[android.intent.category.LAUNCHER] dat= pkg=username
> cmp=com.mypackage/.MyActivity } Error type 3 Error:
> Activity class {com.mypackage/com.mypackage.MyActivity} does not
> exist.
It works on Android 12 and lower.
Couldn't find any information about that except https://developer.android.com/about/versions/13/behavior-changes-all#intents
When I match the Intent filter as mentioned in the link
adb shell am start -a android.intent.action.VIEW -d myscheme://myhost/myprefix -n com.mypackage/com.mypackage.MyActivity
opens but I need to open activty with my parameters without myscheme://myhost/myprefix and View intent
Do you have any idea?
答案1
得分: 1
你可能需要添加一个单独的意图过滤器来启动:
https://automationchronicles.com/error-when-opening-chrome-on-android-13-via-adb/
例如:
<activity
android:name=".mypackage.MyActivity"
android:exported="true"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
</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:host="myhost"
android:scheme="myscheme" />
</intent-filter>
英文:
You probably need to add a separate intent filter to launch:
https://automationchronicles.com/error-when-opening-chrome-on-android-13-via-adb/
e.g.
<activity
android:name=".mypackage.MyActivity"
android:exported="true"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
</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:host="myhost"
android:scheme="myscheme" />
</intent-filter>
</details>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论