am指令带参数启动app

使用am指令启动app

$ adb shell am start com.test/.MainActivity

带参数启动app有两种方法

1. 传入一个字符串

$ adb shell am start -n com.test/.MainActivity -d "hello, world"

app内取数据

getIntent().getDataString()

2. 传入键值对

$ 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");

3. 关闭Activity

$ adb shell input keyevent KEYCODE_BACK

参考链接


发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注