Open GoogleCodeExporter opened 9 years ago
Original comment by damonkoh...@gmail.com
on 6 Nov 2010 at 9:44
It is possible to add a default browser to the list of pythons
webbrowser-module. The module provide for this the method ''register''.
Question:
The only question is which browser is available on the android plattform and
how you can call it from python-code?
Answer:
You can make it possible if you use the function ''droid.view(url)'' of the
SL4A API, that can call an URL in a webbrowser.
The same would happen if you programm an app in java for android and call with
an ''Intent'' the ''Intent.ACTION_VIEW'', give the intent an url and start the
created Intent with the method ''startActivity(intent)''.
So back to the modification of the webbrowser-modul of python.
Now you can create a Webbrowser class in python like this:
# Web browser support for Android combined with the SL4A project.
class AndroidSL4AWebbrowser(object):
def __init__(self):
import android
self.droid = android.Android()
def droid_open(self, url):
self.droid.view(url)
def open(self, url, new=0, autoraise=True):
self.droid_open(url)
def open_new(self, url):
self.droid_open(url)
def open_new_tab(self, url):
self.droid_open(url)
and add this class to the list of pythons webbrowser-modul with the
''register''-method like this:
register('androidsl4awebbrowser', AndroidSL4AWebbrowser, None, -1)
After this you can call in the python-code:
url = ''www.google.de''
webbrowser.open(url)
The only problem is, that the call of the webbrowser.open(url) is not asynchron.
But this is solvable with a Thread.
Original comment by valerij....@gmail.com
on 4 Oct 2012 at 4:12
Attachments:
Original issue reported on code.google.com by
alexandr...@gmail.com
on 7 Mar 2010 at 8:34