Skip to content

Instantly share code, notes, and snippets.


bstaint/ Secret

Created Sep 3, 2019
What would you like to do?
Android native embedded browser modify
import kivy
from import App
from kivy.lang import Builder
from kivy.utils import platform
from kivy.uix.widget import Widget
from kivy.clock import Clock
from jnius import autoclass
from android.runnable import Runnable
WebView = autoclass('android.webkit.WebView')
WebViewClient = autoclass('android.webkit.WebViewClient')
activity = autoclass('').mActivity
def run_ui_thread(f, *args, **kwargs):
# args/kwargs to runnable was a bug, fixed in master
Runnable(f)(args, kwargs)
class Wv(Widget):
def __init__(self, **kwargs):
super(Wv, self).__init__(**kwargs)
Clock.schedule_once(self.create_webview, 0)
def create_webview(self, *args):
def _create_webview(*args):
webview = WebView(activity)
wvc = WebViewClient();
run_ui_thread(_create_webview, *args)
class ServiceApp(App):
def build(self):
return Wv()
if __name__ == '__main__':
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.