问题
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