Discussion:
How to access from ndk activity created in java?
Ilya Nesterov
2018-02-02 01:06:11 UTC
Permalink
Hi,

I'm playing around with native activity and android_native_app_glue. My
current experiment is whether I can access from NDK an activity created
from Java.
So, it is more clear what is going on when you create a native activity,
because when you implement android_main , android_app structure is created
for you and passed to the android_main as a parameter.

My question is: If I create activity in Java, can I access the activity
from native code through JNI?

I think Ill need to create android_app structure manually but
passing ANativeActivity* activity and AConfiguration* config and other
stuff which might be accessible through JNIEnv *env. I want to reference
current activity to catchAMotionEvent_* events.
is it possible? Am I going in the right direction?
--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-ndk+***@googlegroups.com.
To post to this group, send email to android-***@googlegroups.com.
Visit this group at https://groups.google.com/group/android-ndk.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/c2b6d8d4-d0d1-4ebc-bbb8-a4c3be43c761%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Alex Cohn
2018-02-04 18:47:18 UTC
Permalink
I believe you are making your life too hard. NativeActivity is actually a
Java class that alteady implements all hooks necessary to work with the
android_native_app_glue. You can easily *extend* this Java class in Java,
adding whatever you want. If you are careful, you will not have to touch
the glue code on either side of JNI.

BR,
Alex
Post by Ilya Nesterov
Hi,
I'm playing around with native activity and android_native_app_glue. My
current experiment is whether I can access from NDK an activity created
from Java.
So, it is more clear what is going on when you create a native activity,
because when you implement android_main , android_app structure is created
for you and passed to the android_main as a parameter.
My question is: If I create activity in Java, can I access the activity
from native code through JNI?
I think Ill need to create android_app structure manually but
passing ANativeActivity* activity and AConfiguration* config and other
stuff which might be accessible through JNIEnv *env. I want to reference
current activity to catchAMotionEvent_* events.
is it possible? Am I going in the right direction?
--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-ndk+***@googlegroups.com.
To post to this group, send email to android-***@googlegroups.com.
Visit this group at https://groups.google.com/group/android-ndk.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/4b9c87c9-2e4b-44dc-8eb5-c30e899b0be2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...