1.不带参数启动Activity
adb shell am start -n com.app.test/.MainActivity
adb shell am start com.app.test/.MainActivity
2.带参数的启动Activity
adb shell am start -n com.app.test/.MainActivity --ei start_index 1
等同于Java代码:
Intent intent= new Intent();
intent.setComponent(new ComponentName("com.app.test", "com.app.test.MainActivity"));
intent.putExtra("start_index", 1);
startActivity(intent);
3.指定Action
adb shell am start -a android.intent.action.MAIN -n com.app.test/.MainActivity --ei start_index 1
4.指定category
adb shell am start -c android.intent.category.LAUNCHER -n com.app.test/.MainActivity --ei start_index 1
5.同时指定action和category都可以
adb shell am start -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -n com.app.test/.MainActivity --ei start_index 1
对应命令的介绍
-a action;activity对应的action;
--es key stringValue; 传递 String 参数;
--ez key booleanValue; 传递 Boolean 参数;
--ei key intValue; 传递 int 参数;
--el key longValue; 传递 long 参数;
--ef key floatValue; 传递 float 参数;