am指令带参数启动app 使用am指令启动app $ adb shell am start com.test/.MainActivity 1 $ adb shell am start com.test/.MainActivity 带参数启动app有两种方法 1. 传入一个字符串 $ adb shell am start -n com.test/.MainActivity -d "hello, world" 1 $ adb shell am start -n com.test/.MainActivity -d "hello, world" app内取数据 getIntent().getDataString() 1 getIntent().getDataString() 2. 传入键值对 $ adb shell am start -n com.test/.MainActivity --ei num 10 --es str "hello, world" 1 $ adb shell am start -n com.test/.MainActivity --ei num 10 --es str "hello, world" app内通过取数据 ei表示传入的是int es表示传入的是String getIntent().getIntExtra("num"); getIntent().getStringExtra("str"); 1 getIntent().getIntExtra("num"); getIntent().getStringExtra("str"); 3. 关闭Activity $ adb shell input keyevent KEYCODE_BACK 1 $ adb shell input keyevent KEYCODE_BACK 参考链接 android am 启动activity service or broadcast及参数传递 Use android adb shell to return one activity How to send String[] intent extra value from command line?