Sign in to follow this  
polyfrag

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

Recommended Posts

polyfrag    2504
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?

Share this post


Link to post
Share on other sites
frob    44974

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.

Edited by frob

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this