system("am start ..."); Invalid argument

Started by
0 comments, last by frob 11 years ago
I tried
system("am start -a android.intent.action.MAIN -n com.pathogengame.pathogen/com.pathogengame.pathogen.VideoActivity")
and
system("am start -n com.pathogengame.pathogen/com.pathogengame.pathogen.VideoActivity")
and
system("am start -n com.pathogengame.pathogen/.VideoActivity")
But it always returns something other than 0 (doesn't work) and strerror(errno) returns either

Invalid argument

or

Try again.

How can I natively start another activity?
Advertisement

There's the usual issues: Does the app have proper permissions? Does it have the intent filters set up correctly?

Next, there is the fact that your method is contrary to the whole security design of Android. Each app gets a private little virtual machine. Unless specified otherwise, you get one process. Stray processes can be killed by the OS without notice. Calls to system() cause many such things to potentially happen. A few moments searching the Android development groups show this random stray-process reaping as the cause of many crashes.

The right way to do it is use JNI to start your Intent. The NDK does not provide a way to do it. Again per the Android group forums, the dev teams know about the omission from the NDK and have no plans to introduce methods to do it.

This topic is closed to new replies.

Advertisement