exec command android native code

前端 未结 2 1086
日久生厌
日久生厌 2021-01-14 21:05

I am trying to launch an android applications from native code.

In adb shell we can launch applications using \"am\" command.

Link:

How to run (not o

相关标签:
2条回答
  • 2021-01-14 21:32

    you should use system() family method ,first it will fork child process and invoke shell then return,so it will not block android main thread

    0 讨论(0)
  • 2021-01-14 21:33

    I got the answer... I 'exec'ed the shell itself and gave it the command... It worked

    ret = execl("/system/bin/sh", "sh", "-c", "am start -a android.intent.action.MAIN -n   com.android.browser/.BrowserActivity", (char *)NULL);
    

    Thanks to m0skit0, Padma Kumar, Yuri ...

    0 讨论(0)
提交回复
热议问题