开发者

How to have an activity that will run once only? [duplicate]

This question already has an answer here: Closed 11 years ago.

Possible Duplicate:

How do I show an alert dialog only on the first run of my application?

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 pr开发者_开发百科esses '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?

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


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:

  • use a SQLite database
  • use your own file format
  • use a unique device id (careful, Android ID is not really unique) and store it on a remote server
  • store it in a really crazy way, such as a special text message, or a contact, or ...
  • find some way to change your application code (might be possible on a rooted phone?)

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜