Skip to content

armgit / core

Public Imported from GitHub
0

100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps

Consoles: Fixed issue with app not opening on Android from push notification (#855)

Michael Rademaker2fc177308c7e
diff --git a/console/android/ORLib/src/main/java/io/openremote/orlib/service/ORMessagingActionService.kt b/console/android/ORLib/src/main/java/io/openremote/orlib/service/ORMessagingActionService.kt
index 8b03ab94a..e5d778e56 100644
--- a/console/android/ORLib/src/main/java/io/openremote/orlib/service/ORMessagingActionService.kt
+++ b/console/android/ORLib/src/main/java/io/openremote/orlib/service/ORMessagingActionService.kt
@@ -1,12 +1,13 @@
package io.openremote.orlib.service
import android.app.IntentService
-import android.content.Intent
import android.app.NotificationManager
+import android.content.Intent
+import android.content.pm.PackageManager
import android.net.Uri
-import io.openremote.orlib.R
import android.text.TextUtils
import io.openremote.orlib.ORConstants
+import io.openremote.orlib.R
import io.openremote.orlib.ui.OrMainActivity
class ORMessagingActionService : IntentService("org.openremote.android.ORMessagingActionService") {
@@ -55,13 +56,14 @@ class ORMessagingActionService : IntentService("org.openremote.android.ORMessagi
notificationResource!!.executeRequest(httpMethod!!, appUrl, data)
}
else -> {
- val activityIntent = Intent(applicationContext, OrMainActivity::class.java)
- activityIntent.addFlags(
+ val pm: PackageManager = packageManager
+ val launchIntent: Intent = pm.getLaunchIntentForPackage(applicationContext.packageName) ?: Intent(applicationContext, OrMainActivity::class.java)
+ launchIntent.addFlags(
Intent.FLAG_ACTIVITY_NEW_TASK or
Intent.FLAG_ACTIVITY_SINGLE_TOP
)
- activityIntent.putExtra("appUrl", appUrl)
- startActivity(activityIntent)
+ launchIntent.putExtra("appUrl", appUrl)
+ startActivity(launchIntent)
}
}
}
diff --git a/console/android/ORLib/src/main/java/io/openremote/orlib/ui/OrMainActivity.kt b/console/android/ORLib/src/main/java/io/openremote/orlib/ui/OrMainActivity.kt
index de8c52c3e..07dfbb5dd 100644
--- a/console/android/ORLib/src/main/java/io/openremote/orlib/ui/OrMainActivity.kt
+++ b/console/android/ORLib/src/main/java/io/openremote/orlib/ui/OrMainActivity.kt
@@ -430,6 +430,13 @@ open class OrMainActivity : Activity() {
return true
}
+ override fun onGeolocationPermissionsShowPrompt(
+ origin: String?,
+ callback: GeolocationPermissions.Callback?
+ ) {
+ callback?.invoke(origin, true, false)
+ }
+
override fun onProgressChanged(view: WebView, progress: Int) {
progressBar!!.progress = progress
}
@@ -446,9 +453,9 @@ open class OrMainActivity : Activity() {
transport.webView = newWebView
resultMsg.sendToTarget()
newWebView.webViewClient = object : WebViewClient() {
- override fun shouldOverrideUrlLoading(view: WebView, url: String): Boolean {
+ override fun shouldOverrideUrlLoading(view: WebView, request: WebResourceRequest): Boolean {
val browserIntent = Intent(Intent.ACTION_VIEW)
- browserIntent.data = Uri.parse(url)
+ browserIntent.data = request.url
startActivity(browserIntent)
return true
}