• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps How android native app call another native start?

arkceajin

Lurker
I tried to call native from another native app like this:
Native A ⇒ click button to trigger below function to start ⇒ Native B
Code:
std::system("am start -n com.package.name/.activity")
this command can work in ADB, but not work in native application.

So i create Native B as Service, start B service first.
Then let A broadcast a action, let B service do certain job like this:
Code:
std::system("am broadcast -a my_start_action -n com.package.name/.activity")
But still does not worked.[/code]
 
Last edited:
Your question is a little unclear. It would help to clarify things if you posted your code. Use [code][/code] tags to format it.
Thanks.
 
Your question is a little unclear. It would help to clarify things if you posted your code. Use [code][/code] tags to format it.
Thanks.
I solved problem:
Code:
jclass clazz = env->FindClass("android/content/Intent");
jmethodID constructor = env->GetMethodID(clazz, "<init>", "(Ljava/lang/String;)V");
jobject intent = env->NewObject(clazz, constructor, env->NewStringUTF("android.intent.action.START_SERVICE"));
jmethodID startService = env->GetMethodID(env->GetObjectClass(instance), "startService", "(Landroid/content/Intent;)Landroid/content/ComponentName;");
env->CallObjectMethod(instance, startService, intent);
 
Back
Top Bottom