Skip to content

add android:usesCleartextTraffic="true" to sdl2 #2334

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

sharkguto
Copy link

add android:usesCleartextTraffic="true" to sdl2 for using webview with kivy

from kivy.app import App
from jnius import autoclass
from kivy.clock import Clock
from android.runnable import run_on_ui_thread
from kivy.uix.widget import Widget

WebView = autoclass("android.webkit.WebView")
WebSettings = autoclass("android.webkit.WebSettings")
WebViewClient = autoclass("android.webkit.WebViewClient")
activity = autoclass("org.kivy.android.PythonActivity").mActivity


@run_on_ui_thread
def create_webview(*args):
    webview = WebView(activity)
    webview.getSettings().setJavaScriptEnabled(True)
    webview.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW)
    wvc = WebViewClient()
    webview.setWebViewClient(wvc)
    activity.setContentView(webview)
    webview.loadUrl("http://18.15.178.11:9999")


class Wv(Widget):
    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        self.__functionstable__ = {}
        Clock.schedule_once(create_webview, 0)


class ServiceApp(App):
    def build(self):
        return Wv()


if __name__ == "__main__":
    ServiceApp().run()

add android:usesCleartextTraffic="true" to kivy
@vesellov
Copy link
Contributor

vesellov commented Oct 22, 2020

I would like to mention here my PR also, because it is very related... I am adding a parameter for usesCleartextTraffic that can be set via buildozer.spec file... not everyone needs it to be set to true, right ? ;)))

#2338

@vesellov
Copy link
Contributor

vesellov commented Feb 17, 2021

My pull request #2338 was merged and now I think people can achieve same result without modifying the XML template. You can pass input parameter like that and hopefully it should work:

--extra-manifest-application-arguments="android:usesCleartextTraffic=\"true\""

@kuzeyron kuzeyron added the core-providers Core code that's not a recipe label Apr 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core-providers Core code that's not a recipe
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants