如何解决重启android后,Python kivy应用为空
更新:我将.apk文件从ubuntu复制到了我的android手机,每次重启我的android手机时,我都必须安装.apk。
因此,昨晚我在Android上使用buildozer成功启动了我的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,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,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.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()
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com(将#修改为@)