我正在尝试从 native 代码启动 android 应用程序。
在 adb shell 中,我们可以使用“am”命令启动应用程序。
链接:
How to run (not only install) an android application using .apk file?
有什么方法可以通过 C 代码调用这个“am”命令吗?
我尝试了以下行,但 exec 返回 -1:
ret = execl("/system/bin/am", "start", "-a", "android.intent.action.MAIN",
"-n", "com.android.settings/.Settings", (char *)NULL);
这对不对?
最佳答案
我得到了答案... 我“执行”了 shell 本身并给了它命令......它起作用了
ret = execl("/system/bin/sh", "sh", "-c", "am start -a android.intent.action.MAIN -n com.android.browser/.BrowserActivity", (char *)NULL);
感谢 m0skit0、Padma Kumar、Yuri ...
关于android - 执行命令 android native 代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9530131/