android启动native进程

从APP启动native进程以及从native code发送intent。

从APP启动native进程

1
2
3
4
5
try {
Process proc = Runtime.getRuntime().exec("touch /storage/sdcard/xxx.txt");
} catch (IOException e1) {
e1.printStackTrace();
}

从native code发送intent

1
2
3
4
#include <stdlib.h>

int status = -1;
status = system(am broadcast -a com.example.DEMO_ACTION --user 0");