# HG changeset patch # User Goffi # Date 1578151497 -3600 # Node ID a3cefa7158dcbf689b4debbb999a2b18bc542348 # Parent 83697218b9b2fda4c67ac78f165dc96d24f72b9d android: open "geo:" URL using an Intent diff -r 83697218b9b2 -r a3cefa7158dc cagou/core/platform_/android.py --- a/cagou/core/platform_/android.py Sat Jan 04 16:24:57 2020 +0100 +++ b/cagou/core/platform_/android.py Sat Jan 04 16:24:57 2020 +0100 @@ -22,6 +22,7 @@ from jnius import autoclass, cast from android import activity from sat.core import log as logging +from urllib.parse import urlparse from cagou.core.constants import Const as C from cagou import G from kivy.clock import Clock @@ -32,9 +33,13 @@ service = autoclass('org.salutatoi.cagou.ServiceBackend') mActivity = autoclass('org.kivy.android.PythonActivity').mActivity +Intent = autoclass('android.content.Intent') +AndroidString = autoclass('java.lang.String') +Uri = autoclass('android.net.Uri') ImagesMedia = autoclass('android.provider.MediaStore$Images$Media') AudioMedia = autoclass('android.provider.MediaStore$Audio$Media') VideoMedia = autoclass('android.provider.MediaStore$Video$Media') + DATA = '_data' @@ -114,10 +119,9 @@ def on_new_intent(self, intent): log.debug("on_new_intent") - Intent = autoclass('android.content.Intent') action = intent.getAction(); intent_type = intent.getType(); - if action == "android.intent.action.SEND": + if action == Intent.ACTION_SEND: # we have receiving data to share, we parse the intent data # and show the share widget data = {} @@ -149,3 +153,14 @@ f"path: {path}") log.debug(msg) + + def open_url(self, url, wid=None): + parsed_url = urlparse(url) + if parsed_url.scheme == "geo": + intent = Intent(Intent.ACTION_VIEW) + intent.setData(Uri.parse(url)) + if mActivity.getPackageManager() is not None: + activity = cast('android.app.Activity', mActivity) + activity.startActivity(intent) + else: + super().open_url(self, url, wid)