Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: How to broadcast intent from native code?

Tags:

android

Is it possible to broadcast an Intent from native code? If so, is there documentation and/or sample code pertaining to the relevant APIs?

like image 1000
zer0stimulus Avatar asked Nov 02 '10 17:11

zer0stimulus


1 Answers

You will need to call it by calling the Java API function - there is no JNI interface for intents.

First look up the class for Intent, then look up the methods for constructing intents and broadcasting them, and call them.

EDIT: Here is an incomplete example. jniEnv is passed into all your JNI functions.

jclass activityClass = jniEnv->FindClass("android/app/Activity");
jmethodID startAcitivtyMethod = jniEnv->GetMethodID(activityClass , "startActivity", "(Landroid/content/Intent;)V");
jniEnv->CallVoidMethod(yourActivityObject, startAcitivityMethod, yourIntentObject);
like image 194
EboMike Avatar answered Oct 04 '22 08:10

EboMike