diff --git a/src/app/app.cc b/src/app/app.cc index 0dbc5e34b..216c3cef4 100644 --- a/src/app/app.cc +++ b/src/app/app.cc @@ -1125,7 +1125,7 @@ extern "C" { void ANDROID_EXTERNAL(app, App, onCreateAppActivity)( JNIEnv *env, jobject self, - jobject appActivity + jobject activity ) { auto app = App::sharedApplication(); @@ -1133,11 +1133,13 @@ extern "C" { ANDROID_THROW(env, "Missing 'App' in environment"); } - if (app->appActivity) { - app->jni->DeleteGlobalRef(app->appActivity); + if (app->activity) { + app->jni->DeleteGlobalRef(app->activity); } - app->appActivity = env->NewGlobalRef(appActivity); + app->activity = env->NewGlobalRef(activity); + app->core->platform.jvm = Android::JVMEnvironment(app->jni); + app->core->platform.activity = app->activity; app->run(); if (app->windowManager.getWindowStatus(0) == WindowManager::WINDOW_NONE) { @@ -1218,7 +1220,7 @@ extern "C" { void ANDROID_EXTERNAL(app, App, onDestroyAppActivity)( JNIEnv *env, jobject self, - jobject appActivity + jobject activity ) { auto app = App::sharedApplication(); @@ -1226,9 +1228,10 @@ extern "C" { ANDROID_THROW(env, "Missing 'App' in environment"); } - if (app->appActivity) { - env->DeleteGlobalRef(app->appActivity); - app->appActivity = nullptr; + if (app->activity) { + env->DeleteGlobalRef(app->activity); + app->activity = nullptr; + app->core->platform.activity = nullptr; } } diff --git a/src/app/app.hh b/src/app/app.hh index 7de352694..42f470202 100644 --- a/src/app/app.hh +++ b/src/app/app.hh @@ -82,9 +82,9 @@ namespace SSC { Android::BuildInformation androidBuildInformation; Android::Looper androidLooper; Android::JVMEnvironment jvm; + Android::Activity activity = nullptr; + Android::Application self = nullptr; JNIEnv* jni = nullptr; - jobject self = nullptr; - jobject appActivity = nullptr; bool isAndroidEmulator = false; #endif diff --git a/src/app/app.kt b/src/app/app.kt index d13508d26..6171aea14 100644 --- a/src/app/app.kt +++ b/src/app/app.kt @@ -11,6 +11,7 @@ import android.app.NotificationManager import android.content.Intent import android.content.pm.PackageManager import android.content.res.AssetManager +import android.net.Uri import android.os.Build import android.os.Bundle import android.webkit.MimeTypeMap @@ -63,6 +64,13 @@ open class AppActivity : WindowManagerActivity() { ) } + fun openExternal (value: String) { + val uri = Uri.parse(value) + val action = Intent.ACTION_VIEW + val intent = Intent(action, uri) + this.startActivity(intent) + } + override fun onCreate (savedInstanceState: Bundle?) { this.supportActionBar?.hide() this.getWindow()?.statusBarColor = android.graphics.Color.TRANSPARENT diff --git a/src/window/android.cc b/src/window/android.cc index 4bd963236..fe8a32379 100644 --- a/src/window/android.cc +++ b/src/window/android.cc @@ -44,7 +44,7 @@ namespace SSC { // `activity.createWindow(index, shouldExitApplicationOnClose): Unit` CallVoidClassMethodFromAndroidEnvironment( attachment.env, - app->appActivity, + app->activity, "createWindow", "(IZZ)V", options.index, @@ -84,7 +84,7 @@ namespace SSC { CallClassMethodFromAndroidEnvironment( attachment.env, Boolean, - app->appActivity, + app->activity, "evaluateJavaScript", "(ILjava/lang/String;)Z", this->index, @@ -102,7 +102,7 @@ namespace SSC { CallClassMethodFromAndroidEnvironment( attachment.env, Boolean, - app->appActivity, + app->activity, "showWindow", "(I)Z", this->index @@ -117,7 +117,7 @@ namespace SSC { CallClassMethodFromAndroidEnvironment( attachment.env, Boolean, - app->appActivity, + app->activity, "hideWindow", "(I)Z", this->index @@ -140,7 +140,7 @@ namespace SSC { CallClassMethodFromAndroidEnvironment( attachment.env, Boolean, - app->appActivity, + app->activity, "closeWindow", "(I)Z", this->index @@ -168,7 +168,7 @@ namespace SSC { const auto result = CallClassMethodFromAndroidEnvironment( attachment.env, Boolean, - app->appActivity, + app->activity, "navigateWindow", "(ILjava/lang/String;)Z", this->index, @@ -188,7 +188,7 @@ namespace SSC { // `activity.getWindowTitle(index): String` const auto titleString = (jstring) CallObjectClassMethodFromAndroidEnvironment( attachment.env, - app->appActivity, + app->activity, "getWindowTitle", "(I)Ljava/lang/String;", this->index @@ -206,7 +206,7 @@ namespace SSC { CallClassMethodFromAndroidEnvironment( attachment.env, Boolean, - app->appActivity, + app->activity, "setWindowTitle", "(ILjava/lang/String;)Z", this->index,