On Thu, Jul 19, 2012 at 9:49 AM, HV <harishv.athr...@gmail.com> wrote:

> The native code is in a library that is already loaded & running. So, I
> need something like "reverse" JNI (calling a Java method from C++).


That is not "reverse" JNI, that is a basic part of JNI.


> I was able to create a .jar file (which has the Intent call to launch 3rd
> party apps), putting it in the CLASSPATH in init.rc & FindClass/GetMethodID
> do succeed now.


Er...  what?!?

I so don't understand.  You have your app, which must have Java code on it.
 You have your native code.  Use JNI to call the Java code.  If you need
some implementation in Java, put it in your Java code.

Hell, if you just want to start an activity, you wouldn't even need any
Java code (I just think it is easier to write that part in Java), you can
write JNI that creates an Intent object and calls the methods to set it up,
and then calls startActivity on the Context.  You do need to pass in the
Context (which here will be your Activity object) at some point to your
native code...  but you made your native code run, so you called it at some
point, so you can do that.

If you are using NativeActivity and so have not written any Java code (so
have the illusion of a "pure native" application), the native activity C
data structures include the Activity object which you can use to do the
startActivity call.  Also you can change your app to have some Java code
which implements a subclass of NativeActivity which is the thing that gets
run.  Then you can put your Java code there.

Also I would suggest going and looking at android-ndk, because this is
basic stuff that people talk about doing when developing with the NDK.


> The issue is with CallVoidMethod which is failing since the .jar file is
> not running (unlike the earlier case where in I had a .apk which had an
> icon on the desktop that i could just launch easily). Any idea how I can
> run the jar file?
>

Don't.  Put it in your regular app.

-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

-- 
unsubscribe: android-porting+unsubscr...@googlegroups.com
website: http://groups.google.com/group/android-porting

Reply via email to