@@ -168,7 +168,7 @@ cdef extern void android_show_keyboard(int)
168168cdef extern void android_hide_keyboard()
169169
170170
171- from jnius import autoclass, PythonJavaClass, java_method
171+ from jnius import autoclass, PythonJavaClass, java_method, cast
172172
173173# API versions
174174api_version = autoclass(' android.os.Build$VERSION' ).SDK_INT
@@ -318,23 +318,28 @@ IF IS_PYGAME:
318318 def ack_stop ():
319319 android_ackstop()
320320
321- # -------------------------------------------------------------------
322- # URL Opening.
323- cdef extern void android_open_url(char * url)
324- def open_url (url ):
325- android_open_url(url)
321+ # -------------------------------------------------------------------
322+ # URL Opening.
323+ def open_url (url ):
324+ Intent = autoclass(' android.content.Intent' )
325+ Uri = autoclass(' android.net.Uri' )
326+ browserIntent = Intent()
327+ browserIntent.setAction(Intent.ACTION_VIEW)
328+ browserIntent.setData(Uri.parse(url))
329+ currentActivity = cast(' android.app.Activity' , mActivity)
330+ currentActivity.startActivity(browserIntent)
331+
332+ # Web browser support.
333+ class AndroidBrowser (object ):
334+ def open (self , url , new = 0 , autoraise = True ):
335+ open_url(url)
336+ def open_new (self , url ):
337+ open_url(url)
338+ def open_new_tab (self , url ):
339+ open_url(url)
326340
327- # Web browser support.
328- class AndroidBrowser (object ):
329- def open (self , url , new = 0 , autoraise = True ):
330- open_url(url)
331- def open_new (self , url ):
332- open_url(url)
333- def open_new_tab (self , url ):
334- open_url(url)
335-
336- import webbrowser
337- webbrowser.register(' android' , AndroidBrowser, None , - 1 )
341+ import webbrowser
342+ webbrowser.register(' android' , AndroidBrowser, None , - 1 )
338343
339344cdef extern void android_start_service(char * , char * , char * )
340345def start_service (title = None , description = None , arg = None ):
@@ -383,3 +388,5 @@ class AndroidService(object):
383388 ''' Stop the service.
384389 '''
385390 stop_service()
391+
392+
0 commit comments