如何有将仅运行一次的活动? [英] How to have an activity that will run once only?

查看:110
本文介绍了如何有将仅运行一次的活动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
  <一href="http://stackoverflow.com/questions/5409595/how-do-i-show-an-alert-dialog-only-on-the-first-run-of-my-application">How我只显示在我的应用程序第一次运行一个警告对话框?

在我的应用程序将有条款和条件的活动,显示以及确定一些条件和取消按钮,当用户presses确定按钮的应用程序,继续,继续运行。当用户启动这个下一次应用程序的条款和条件的活动绝不能运行其已经接受了。如何获得这样的功能在我的应用程序?

In my app there will be a Terms and Conditions activity which shows some conditions along with ok and cancel buttons, and when the user presses 'ok' button the app continue and go on running. Next time when the user starts this app the Terms and Conditions activity must not run as its already accepted before. How to get such a functionality in my app?

我不想使用共享preferences或内部应用程序的内存。我想自定义的发射活动的意图。

I don't want to use shared preferences or internal app memory. I want to customize the launch of intent between activities.

推荐答案

为什么你不希望使用共享preferences?这将是迄今为止最容易。当然,你能想到的,不要使用共享preferences更复杂的方式,但你必须存储在某个地方。一些混乱的方式:

Why don't you want to use the shared preferences? This would be by far the easiest. Of course you can think of more complicated ways that don't use shared preferences, but you have to store it somewhere. Some messier ways:

  • 使用SQLite数据库
  • 使用自己的文件格式
  • 使用一个唯一的设备ID(小心,Android的ID是不是真的唯一的),并将其存储在远程服务器上
  • 将其存放在一个非常疯狂的方法,如特殊的文字信息,或联系人,或者...
  • 找到一些方法来改变你的应用程序code(也许可以在一个植根电话?)

要总结:共享preferences由这种类型的东西。有用。用它。没有真的。

To summarize: SharedPreferences is made for this type of thing. It works. Use it. No really.

这篇关于如何有将仅运行一次的活动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆