You've already forked android_translation_layer
mirror of
https://gitlab.com/android_translation_layer/android_translation_layer.git
synced 2025-10-27 11:48:10 -07:00
get Application class from AndroidManifest.xml and call onCreate()
This commit is contained in:
@@ -161,6 +161,7 @@ static void open(GtkApplication *app, GFile** files, gint nfiles, const gchar* h
|
||||
int errno_localdir;
|
||||
int ret;
|
||||
jobject activity_object;
|
||||
jobject application_object;
|
||||
|
||||
char *apk_classpath = g_file_get_path(files[0]);
|
||||
char *apk_name = g_file_get_basename(files[0]);
|
||||
@@ -343,12 +344,22 @@ static void open(GtkApplication *app, GFile** files, gint nfiles, const gchar* h
|
||||
|
||||
gtk_window_present(GTK_WINDOW(window));
|
||||
|
||||
// construct Application
|
||||
application_object = (*env)->CallStaticObjectMethod(env, handle_cache.context.class,
|
||||
_STATIC_METHOD(handle_cache.context.class, "createApplication", "()Landroid/app/Application;"));
|
||||
if((*env)->ExceptionCheck(env))
|
||||
(*env)->ExceptionDescribe(env);
|
||||
|
||||
extract_from_apk("assets/", "assets/");
|
||||
/* extract native libraries from apk*/
|
||||
extract_from_apk("lib/" NATIVE_ARCH "/", "lib/");
|
||||
|
||||
prepare_main_looper(env);
|
||||
|
||||
(*env)->CallVoidMethod(env, application_object, _METHOD(handle_cache.application.class, "onCreate", "()V"));
|
||||
if((*env)->ExceptionCheck(env))
|
||||
(*env)->ExceptionDescribe(env);
|
||||
|
||||
// construct main Activity
|
||||
activity_object = (*env)->CallStaticObjectMethod(env, handle_cache.apk_main_activity.class,
|
||||
_STATIC_METHOD(handle_cache.apk_main_activity.class, "createMainActivity", "(Ljava/lang/String;J)Landroid/app/Activity;"),
|
||||
@@ -363,7 +374,7 @@ static void open(GtkApplication *app, GFile** files, gint nfiles, const gchar* h
|
||||
if((*env)->ExceptionCheck(env))
|
||||
(*env)->ExceptionDescribe(env);
|
||||
|
||||
/* const char *app_icon_path = _CSTRING((*env)->CallObjectMethod(env, handle_cache.application.object, handle_cache.application.get_app_icon_path));
|
||||
/* const char *app_icon_path = _CSTRING((*env)->CallObjectMethod(env, application_object, handle_cache.application.get_app_icon_path));
|
||||
if((*env)->ExceptionCheck(env))
|
||||
(*env)->ExceptionDescribe(env);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user