You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am to make an android webview app with p4a using kivy example.
from kivy.app import App
from kivy.lang import Builder
from kivy.utils import platform
from kivy.uix.widget import Widget
import webbrowser
from kivy.clock import Clock
from jnius import autoclass
from android.runnable import run_on_ui_thread
WebView = autoclass('android.webkit.WebView')
WebViewClient = autoclass('android.webkit.WebViewClient')
activity = autoclass('org.kivy.android.PythonActivity').mActivity
urlc='https://www.google.co.in'
url='https://www.google.co.in'
class Wv(Widget):
def __init__(self, **kwargs):
super(Wv, self).__init__(**kwargs)
Clock.schedule_once(self.create_webview, 0)
@run_on_ui_thread
def create_webview(self, *args):
webview = WebView(activity)
webview.getSettings().setJavaScriptEnabled(True)
settings.setSupportZoom(True) # enables zoom
settings.setBuiltInZoomControls(True) # enables zoom controls
wvc = WebViewClient();
webview.setWebViewClient(wvc);
activity.setContentView(webview)
# webview.loadUrl('https://www.google.co.in')
if (url.find(urlc)==-1):
webbrowser.open(url)
else:
webview.loadUrl(url)
class ServiceApp(App):
def on_pause(self):
return True
def on_resume(self):
pass
def build(self):
return Wv()
if __name__ == '__main__':
ServiceApp().run()
I am trying for a behavior that all external link should open in webbrowser and internal link in webview.
But with above code app shows all links in webview only.
The command used to make apk:
p4a apk --private /home/user/kiviapps/webview/ --package=org.example.app1 --name "appname" --version 0.1 --bootstrap=sdl2 --requirements=kivy==master,pyjnius,android --permission INTERNET
The text was updated successfully, but these errors were encountered:
So the point is that either webbrowser.open doesn't open in a new Activity, or url.find(urlc) never equals -1? I would test each of these things individually to try to understand the problem, I don't know offhand why this wouldn't work.
I am to make an android webview app with p4a using kivy example.
I am trying for a behavior that all external link should open in webbrowser and internal link in webview.
But with above code app shows all links in webview only.
The command used to make apk:
p4a apk --private /home/user/kiviapps/webview/ --package=org.example.app1 --name "appname" --version 0.1 --bootstrap=sdl2 --requirements=kivy==master,pyjnius,android --permission INTERNET
The text was updated successfully, but these errors were encountered: