Using ADB to launch an activity while using putExtra

前提是你 提交于 2021-02-19 05:25:08

问题


I've been trying to use the Android Documentation to determine how to start an activity with putExtra. My putExtra value is of type String and I've tried numerous combinations of "true", "1", putting the string in quotes. I've tried switching the flags to "-n", "-a", etc... Can somebody point out what I'm doing wrong here? I've ready many other articles but they are usually for some built in intent. I'm starting my own custom intent.

Starting an intent with a string key.

-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE>
Add string data as a key-value pair.
--esn <EXTRA_KEY>
Add a null extra. This option is not supported for URI intents.

Specifications for

-a <ACTION>
Specify the intent action, such as "android.intent.action.VIEW". You can declare this only once.
-n <COMPONENT>
Specify the component name with package name prefix to create an explicit intent, such as "com.example.app/.ExampleActivity".
-f <FLAGS>
Add flags to the intent, as supported by setFlags().

Java

    Intent intent = new Intent(this, PrepareDeviceTestActivity.class);
    intent.putExtra(PrepareDeviceFragment.MANUAL_CALIBRATE, true);
    startActivity(intent);

ADB

adb shell am start -a android.intent.action.VIEW -c android.intent.category.DEFAULT --es calibrate true -n com.package.name/.ui.PrepareDeviceTestActivity

and

adb shell am start -n com.package.name/.ui.PrepareDeviceTestActivity --es calibrate true

来源:https://stackoverflow.com/questions/36040166/using-adb-to-launch-an-activity-while-using-putextra

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!