Reputation: 67
I want to turn off/on wifi in Kivy App. For this work, I used:
from wifidroid.wifi import WifiManager
wifi = WifiManager()
wifi.EnabledWifi(False) #True
I also added permission
in Buildozer.spec:
android.permissions = CHANGE_WIFI_STATE, ACCESS_WIFI_STATE, INTERNET
This method works fine, But the problem is that I have to give "allow" every time for turn off wifi.
I researched this, came to the conclusion that I could create permission
in the program as well. so I used the following code.
if platform == 'android':
from android.permissions import request_permissions, Permission
request_permissions([Permission.CHANGE_WIFI_STATE])
After adding the above three lines, The app crashes during execution. In debug mode it gives this message.
08-31 01:48:47.898 32527 32549 I python : Initializing Python for Android
08-31 01:48:47.899 32527 32549 I python : Setting additional env vars from p4a_env_vars.txt
08-31 01:48:47.899 32527 32549 I python : Changing directory to the one provided by ANDROID_ARGUMENT
08-31 01:48:47.899 32527 32549 I python : /data/user/0/org.kivy.oscservice/files/app
08-31 01:48:47.899 32527 32549 I python : Preparing to initialize python
08-31 01:48:47.899 32527 32549 I python : _python_bundle dir exists
08-31 01:48:47.899 32527 32549 I python : calculated paths to be...
08-31 01:48:47.899 32527 32549 I python : /data/user/0/org.kivy.oscservice/files/app/_python_bundle/stdlib.zip:/data/user/0/org.kivy.oscservice/files/app/_python_bundle/modules
08-31 01:48:47.899 32527 32549 I python : set wchar paths...
08-31 01:48:48.020 32527 32549 I python : Initialized python
08-31 01:48:48.020 32527 32549 I python : AND: Init threads
08-31 01:48:48.024 32527 32549 I python : AND: Ran string
08-31 01:48:48.024 32527 32549 I python : Run user program, change dir and execute entrypoint
08-31 01:48:49.050 32476 32506 I python : [WARNING] [Base ] Unknown <android> provider
08-31 01:48:49.050 32476 32506 I python : [INFO ] [Base ] Start application main loop
08-31 01:48:49.054 32476 32506 I python : Python for android ended.
How can I create a permission message that the user will allow forever?
Upvotes: 0
Views: 587