我如何可以执行一些只有一次每个应用程序的启动? [英] How can I execute something just once per application start?
问题描述
我想在一个应用程序中实现更新检查,而我明明只需要这显示了一旦当你启动应用程序。如果我在的onCreate()
或 ONSTART()
方法的调用,它会在每次显示活性被创建,这不是一个可行的解决方案。
I'd like to implement an update checker in an application, and I obviously only need this to show up once when you start the application. If I do the call in the onCreate()
or onStart()
method, it'll be shown every time the activity is created and this is not a viable solution.
所以我的问题是:?有没有办法做一些事情,比如检查更新,每个应用程序启动只有一次/启动
我,如果它是一个有点难以理解,我有困难的地名释义自己在这一个遗憾。
I'm sorry if it's a bit hard to understand, I'm having difficulties explaning myself on this one.
推荐答案
是的,你可以做到这一点使用共享prefernce机器人的概念。只要创建一个布尔标志,并将其保存在共享prefernce并检查它的价值在你的onCreate()方法。
Yes you can do it Using SharedPrefernce concept of android. Just create a boolean flag and save it in SharedPrefernce and check its value in your onCreate() method .
这篇关于我如何可以执行一些只有一次每个应用程序的启动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!