如何在用户关闭Android kivy应用程序后恢复上一个活动?

2024-07-06 18:26:19 发布

您现在位置:Python中文网/ 问答频道 /正文

我创建了一个具有记忆功能、答案历史记录和其他功能的计算器,即使用户完全关闭了计算机,这些功能也需要保持存储状态

Kivy有一个主应用程序类的on_pauseon_resume方法,可用于在挂起且未关闭时恢复应用程序

如果应用程序关闭,用户是否可以恢复到最近的活动

请帮帮我,谢谢


Tags: 方法记忆答案用户功能应用程序历史记录on
1条回答
网友
1楼 · 发布于 2024-07-06 18:26:19

您可以使用Json文件

from kivy.storage.jsonstore import JsonStore

store = JsonStore('file name.json')

# put some values
store.put('tito', name='Mathieu', org='kivy')
store.put('tshirtman', name='Gabriel', age=27)

# using the same index key erases all previously added key-value pairs
store.put('tito', name='Mathieu', age=30)

# get a value using a index key and key
print('tito is', store.get('tito')['age'])

# or guess the key/entry for a part of the key
for item in store.find(name='Gabriel'):
    print('tshirtmans index key is', item[0])
    print('his key value pairs are', str(item[1]))

More information

相关问题 更多 >