I have an application using NativeActivity. I want to call out into Java to do something that requires a Context (e.g., accessing TelephonyManager to query the IMEI).
How do I get a valid Context for my activity?
The ANativeActivity structure contains a variety of useful data for my application, such as the JavaVM, and JNI environment, etc. It also contains a jobject pointing at my NativeActivity's class object. What it doesn't contain is a jobject pointing at the NativeActivity's instance. I don't see anything useful in struct android_app
, either.
It must be possible to do this; any ideas how?
Despite its name the clazz
member of ANativeActivity
struct is actually pointing to android.app.NativeActivity
instance.
Check this post for an example of using a JNI call from the Native Activity to Java code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With