Thank you!! But it fails here:
i.setDataAndType(Uri.fromFile(KML), "application/vnd.google-earth.kml+xml")
# These didn't work: "xml", "text/xml", "application/xml"
This doesn't work either:
i.setData(Uri.fromFile(KML))
I found the MIME type "application/vnd.google-earth.kml+xml" here:
This is the current version of my test app. (As I recall, the old Google Groups user interface supported formatting Python code nicely? The following looks awful!):
from kivy.app import App
from kivy.lang import Builder
import kivy
from kivy.uix.boxlayout import BoxLayout
kivy.require('1.11.1')
# Developed in Python 3.6 (and 3.8)
from jnius import autoclass # But not: , mActivity
from android import mActivity # But not: , autoclass
# These lines MUST be outside of a Python Class
# Intent = autoclass('android.content.Intent')
File = autoclass('java.io.File')
Uri = autoclass('android.net.Uri')
Builder.load_string('''
#:kivy 1.11.1
#:import kivy kivy
''')
class PyjniusScreen(BoxLayout):
def __init__(self, **kwargs):
super().__init__(**kwargs)
print("NOW starting 'PyjniusScreen'")
# In a Kivy app, these lines will be inside a Python Class
try:
KML = File("myplaces-16x8-Emilie-Meng-pejlinger-2.kml") # /sdcard/doc.kml
try:
print("TRY to find Google Earth.")
i = mActivity.getPackageManager().getLaunchIntentForPackage("com.google.earth")
print("TRY to set KML file for Google Earth.")
i.setDataAndType(Uri.fromFile(KML), "application/vnd.google-earth.kml+xml")
# These didn't work: "xml", "text/xml", "application/xml"
# i.setData(Uri.fromFile(KML)) # Didn't work either.
print("START Google Earth.")
mActivity.startActivity(i)
except:
print("Google Earth didn't work.")
except:
print("The KML file could not be found.")
class MainApp(App):
def build(self):
print("NOW running 'mainApp'")
pyjniusscreen = PyjniusScreen()
return pyjniusscreen
def on_stop(self):
print("Closing Application")
if __name__ == '__main__':
mainApp = MainApp()
print("NOW running 'main'")
mainApp.run()
I used this Terminal command to read the output from the Android device:
$ adb logcat | grep -i " python "
Here comes the essence of the output of that command:
11-17 21:24:14.213 29015 29042 I python : NOW running 'main'
11-17 21:24:14.215 29015 29042 I python : NOW running 'mainApp'
11-17 21:24:14.438 29015 29042 I python : NOW starting 'PyjniusScreen'
11-17 21:24:14.438 29015 29042 I python : TRY to find Google Earth.
11-17 21:24:14.443 29015 29042 I python : TRY to set KML file for Google Earth.
11-17 21:24:14.443 29015 29042 I python : Google Earth didn't work.
Here comes a larger excerpt:
11-17 21:24:11.018 29015 29042 I python : Android kivy bootstrap done. __name__ is __main__
11-17 21:24:11.018 29015 29042 I python : AND: Ran string
11-17 21:24:11.018 29015 29042 I python : Run user program, change dir and execute entrypoint
11-17 21:24:11.299 29015 29042 I python : [WARNING] [Config ] Older configuration version detected (0 instead of 21)
11-17 21:24:11.299 29015 29042 I python : [WARNING] [Config ] Upgrading configuration in progress.
11-17 21:24:11.315 29015 29042 I python : [INFO ] [Logger ] Record log in /data/user/0/dk.transformation.geoespearthtest/files/app/.kivy/logs/kivy_20-11-17_0.txt
11-17 21:24:11.315 29015 29042 I python : [INFO ] [Kivy ] v2.0.0rc3, git-Unknown, 20201117
11-17 21:24:11.316 29015 29042 I python : [INFO ] [Kivy ] Installed at "/data/user/0/dk.transformation.geoespearthtest/files/app/_python_bundle/site-packages/kivy/__init__.pyc"
11-17 21:24:11.316 29015 29042 I python : [INFO ] [Python ] v3.8.1 (default, Sep 17 2020, 10:34:53)
11-17 21:24:11.316 29015 29042 I python : [Clang 8.0.2 (
https://android.googlesource.com/toolchain/clang 40173bab62ec7462
11-17 21:24:11.316 29015 29042 I python : [INFO ] [Python ] Interpreter at ""
11-17 21:24:13.201 29015 29042 I python : [INFO ] [Factory ] 185 symbols loaded
11-17 21:24:14.077 29015 29042 I python : [INFO ] [Image ] Providers: img_tex, img_dds, img_sdl2, img_pil (img_ffpyplayer, img_gif ignored)
11-17 21:24:14.213 29015 29042 I python : NOW running 'main'
11-17 21:24:14.215 29015 29042 I python : NOW running 'mainApp'
11-17 21:24:14.278 29015 29042 I python : [INFO ] [Window ] Provider: sdl2
11-17 21:24:14.345 29015 29042 I python : [INFO ] [GL ] Using the "OpenGL ES 2" graphics system
11-17 21:24:14.349 29015 29042 I python : [INFO ] [GL ] Backend used <sdl2>
11-17 21:24:14.349 29015 29042 I python : [INFO ] [GL ] OpenGL version <b'OpenGL ES 3.2 V@269.0 (GIT@bb5b86c, I77d3059488) (Date:06/07/18)'>
11-17 21:24:14.350 29015 29042 I python : [INFO ] [GL ] OpenGL vendor <b'Qualcomm'>
11-17 21:24:14.350 29015 29042 I python : [INFO ] [GL ] OpenGL renderer <b'Adreno (TM) 505'>
11-17 21:24:14.351 29015 29042 I python : [INFO ] [GL ] OpenGL parsed version: 3, 2
11-17 21:24:14.351 29015 29042 I python : [INFO ] [GL ] Texture max size <16384>
11-17 21:24:14.352 29015 29042 I python : [INFO ] [GL ] Texture max units <16>
11-17 21:24:14.435 29015 29042 I python : [INFO ] [Window ] auto add sdl2 input provider
11-17 21:24:14.436 29015 29042 I python : [INFO ] [Window ] virtual keyboard not allowed, single mode, not docked
11-17 21:24:14.438 29015 29042 I python : NOW starting 'PyjniusScreen'
11-17 21:24:14.438 29015 29042 I python : TRY to find Google Earth.
11-17 21:24:14.443 29015 29042 I python : TRY to set KML file for Google Earth.
11-17 21:24:14.443 29015 29042 I python : Google Earth didn't work.
11-17 21:24:14.445 29015 29042 I python : [WARNING] [Base ] Unknown <android> provider
11-17 21:24:14.445 29015 29042 I python : [INFO ] [Base ] Start application main loop
And help would be deeply appreciated!