Code: Select all
from kivymd.app import MDApp
from kivy.base import Builder
from kivymd.toast import toast
from android.permissions import request_permissions, Permission
import ssl
import requests
# Import necessary Android modules
from jnius import autoclass
from android import mActivity
# Request storage permission
request_permissions([Permission.WRITE_EXTERNAL_STORAGE,Permission.READ_EXTERNAL_STORAGE])
# Get the storage path
context = mActivity.getApplicationContext()
storage_path = os.path.join(os.environ['EXTERNAL_STORAGE'], 'Download')
KV='''
#my design
'''
class MainApp(MDApp):
def __init__(self, **kwargs):
super().__init__(**kwargs)
def build(self):
return Builder.load_string(KV)
def download_site(self):
try:
url = self.root.ids.site_link.text
response = requests.get(url,verify=False)
if response.status_code == 200:
filename = os.path.join(storage_path, 'site.html')
with open(filename, 'w', encoding='utf-8') as file:
file.write(response.text)
toast("Webpage source saved")
else:
toast("Failed to save webpage source.")
except Exception as e:
toast('Please check your Internet Connection')
print(str(e))
MainApp().run()
So sieht meine App zur Laufzeit aus
Und so sehen andere Apps aus So sieht es während der Laufzeit aus. Ich möchte, dass meine App dieselben Berechtigungen wie diese App anfordert.
Ich benötige eine Dateizugriffsberechtigung, um eine Datei zu erstellen