重启android后Python kivy应用程序空白
更新:我将.apk文件从ubuntu复制到我的android手机上,每次重启android手机时我都要安装.apk,这很无聊 所以昨天晚上,我使用buildozer在android上成功地启动了我的kivy python应用程序,它运行正常。但它不会动态更新我的android手机上的值,今天我重新启动了手机,应用程序现在是空白的。另外,请注意,我在代码中使用了kivy.urlrequest。所以我有两个问题:当应用程序打开时动态更新应用程序中的值,并且即使在重新启动我的android手机后,应用程序也应该工作 我错过了什么?请帮忙 示例代码如下:重启android后Python kivy应用程序空白,python,android,kivy,buildozer,urlrequest,Python,Android,Kivy,Buildozer,Urlrequest,更新:我将.apk文件从ubuntu复制到我的android手机上,每次重启android手机时我都要安装.apk,这很无聊 所以昨天晚上,我使用buildozer在android上成功地启动了我的kivy python应用程序,它运行正常。但它不会动态更新我的android手机上的值,今天我重新启动了手机,应用程序现在是空白的。另外,请注意,我在代码中使用了kivy.urlrequest。所以我有两个问题:当应用程序打开时动态更新应用程序中的值,并且即使在重新启动我的android手机后,应用
from kivy.app import App
from kivy.uix.floatlayout import FloatLayout
from kivy.network.urlrequest import UrlRequest
from kivy.uix.label import Label
from kivy.uix.button import Button
import json
import certifi
class MainScreen(FloatLayout):
def __init__(self, **kwargs):
super(MainScreen, self).__init__(**kwargs)
self.a = None
self.test_connection()
print(" I am in init")
def on_getCloudEvents_success(self,request,result):
print("on_getCloudEvents_success called:")
print(" result="+str(result))
self.resp = result
self.SYNC_REQUEST_STAT="Success" # to end the synchronous wait
self.after_success()
def on_getCloudEvents_failure(self,request,result):
print("on_getCloudEvents_failure called:")
print(" request was sent to "+str(request.url))
print(" request body="+str(request.req_body))
print(" request headers="+str(request.req_headers))
print(" result="+str(request.result))
self.SYNC_REQUEST_STAT="Failure" # to end the synchronous wait
self.after_success()
def on_getCloudEvents_error(self,request,result):
print("on_getCloudEvents_error called:")
print(" request was sent to "+str(request.url))
print(" request body="+str(request.req_body))
print(" request headers="+str(request.req_headers))
print(" result="+str(request.result))
self.SYNC_REQUEST_STAT="Error" # to end the synchronous wait
self.after_success()
def after_success(self):
# button = Button(text='Hello world'+self.a)
# self.add_widget(button)
self.a = "heree"
label = Label(text='Hello from Kivy'+self.SYNC_REQUEST_STAT,
size_hint=(.5, .5),
pos_hint={'center_x': .5, 'center_y': .5},
color = [1.4, 1, 1, 1.8])
self.add_widget(label)
return self
def test_connection(self):
print(jdata)
scan_url = 'https://scanner.tradingview.com/crypto/scan'
UrlRequest(scan_url, ca_file = certifi.where,
verify=True,
on_success=self.on_getCloudEvents_success,
on_failure=self.on_getCloudEvents_failure,
on_error=self.on_getCloudEvents_error)
class App(App):
def build(self):
return MainScreen()
if __name__ == "__main__":
App().run()