1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
1. call this from c>java, on main UI thread, as main activity is created

JNIEnv*		g_envApp			=	0;
jobject		g_objApp			=	0;
jclass		g_classApp			=	0;
jmethodID	g_methodOpenURL		=	0;

JNIEXPORT void JNICALL Java_com_mrqwak_app_AppActivity_onCreateN(JNIEnv *env, jobject obj)
{
	g_envApp = env;
	g_objApp = obj;
	g_classApp = env->GetObjectClass(obj);
	if (g_classApp)
	{
		g_methodOpenURL = env->GetMethodID(g_classApp,"openURL","(Ljava/lang/String;)V");
	}
}


2. call this later, from c>java, NOT on main UI thead, when user presses a button to open a url

extern	JNIEnv*		g_envApp;
extern	jobject		g_objApp;
extern	jclass		g_classApp;
extern	jmethodID	g_methodOpenURL;

void cHTTP::OpenURL(const char* psURL)
{
	if (g_methodOpenURL)
	{
		jstring jstr = g_envApp->NewStringUTF(psURL);
		g_envApp->CallVoidMethod(g_objApp,g_methodOpenURL,jstr);
	}
}