我一直在尝试使用安卓文档 http://developer.android.com/tools/help/shell.html确定如何使用 putExtra 启动活动。我的 putExtra 值是 String 类型,我尝试了“true”、“1”的多种组合,将字符串放在引号中。我尝试将标志切换为“-n”、“-a”等...有人能指出我在这里做错了什么吗?我已经准备了许多其他文章,但它们通常是为了某些内在的意图。我正在开始我自己的定制意图。
使用字符串键启动意图。
-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.
规格
-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