[android-porting] Re: launching apps from native code

2012-07-07 Thread Sandeep Kumar
try below:- ret = execl("/system/bin/sh", "sh", "-c", "am start -a android.intent.action.MAIN -n com.android.browser/.BrowserActivity", (char *)NULL); On Saturday, July 7, 2012 3:51:58 AM UTC+9, HV wrote: > > Wanted to know what is the best practice to launch apps from native code? > Is u

Re: [android-porting] Re: launching apps from native code

2012-07-07 Thread Dianne Hackborn
No don't do that, the am command is not part of the SDK, and doing it this way is horrible inefficient (you need to spin up and initialize a fresh Dalvik vm for the am command, which takes a second or more), and usually totally broken because you are not launching the activity from your own context

Re: [android-porting] Re: launching apps from native code

2012-07-07 Thread HV
Thanks Dianne, that's what I thought, hence this question. Glad to know that using 'am' is not the way to go. Could you please provide a link to the SDK where it talks about this? If there is an example, that'll be awesome Thanks again HV On Saturday, July 7, 2012 5:13:07 PM UTC-7, Dianne Hack

Re: [android-porting] Re: launching apps from native code

2012-07-17 Thread HV
Ok, I got this working. A simple JAVA app (say JNIDemo) that calls a native method (in say NativeLib.so), which in turn calls back a JNIDemo method. All of this is working seamlessly. Now, the next problem I have is context related. I have a desktop icon which is supposed to launch an Android ap

Re: [android-porting] Re: launching apps from native code

2012-07-17 Thread Dianne Hackborn
What is "DesktopIcon"? I don't understand what you are describing. On Tue, Jul 17, 2012 at 2:46 PM, HV wrote: > Ok, I got this working. A simple JAVA app (say JNIDemo) that calls a > native method (in say NativeLib.so), which in turn calls back a JNIDemo > method. All of this is working seamles

Re: [android-porting] Re: launching apps from native code

2012-07-18 Thread HV
The desktop icon is for the simple java app (JNIDemo.apk). I guess what I need is a way of calling a Java method from a native library without having to do a load library from the Java app. Is that possible? If I load the library from JNIdemo, then there will be 2 contexts of the library, one f

Re: [android-porting] Re: launching apps from native code

2012-07-18 Thread HV
After some more reading, found that I could to do these from my native code: options[0].optionString = "-verbose:jni"; vm_args.version = JNI_VERSION_1_6; vm_args.options = options; vm_args.nOptions = 1; vm_args.ignoreUnrecognized = 1; result = JNI_CreateJavaVM(&p_jvm, &en

Re: [android-porting] Re: launching apps from native code

2012-07-18 Thread Dianne Hackborn
I really don't understand. How is your native code running at all if you haven't loaded the library? On Wed, Jul 18, 2012 at 1:07 PM, HV wrote: > The desktop icon is for the simple java app (JNIDemo.apk). I guess what I > need is a way of calling a Java method from a native library without havi

Re: [android-porting] Re: launching apps from native code

2012-07-19 Thread HV
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++). 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 su

Re: [android-porting] Re: launching apps from native code

2012-07-19 Thread Dianne Hackborn
On Thu, Jul 19, 2012 at 9:49 AM, HV 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

Re: [android-porting] Re: launching apps from native code

2012-07-19 Thread HV
Ok, I called it reverse since I am now able to detect a Java class from native code without having to do a System.load(nativelib.so) from the Java code. Let me try to explain my usage: 1. I have nativelib.so that is loaded & running from where I need to launch a 3rd party app. Right now, I'm do

Re: [android-porting] Re: launching apps from native code

2012-07-19 Thread Oyin Oluwatimi
Hey Someone directed to this group. After fiddling with AOSP through the command line for weeks, I recently downloaded eclipse with sdk and ndk installed. My professor wants me to add security extensions to the android platform via the NDK, but I have no idea where to start. Here is what he ex