显示设置屏幕仅在Android的首次发射 [英] Showing the setup screen only on first launch in android
问题描述
我想提出一个Android应用程序,但我无法弄清楚如何我可以设置屏幕显示仅在第一次。 这是应用程序将如何工作的: 用户在安装后启动应用程序并正在显示欢迎/设置屏幕。一旦用户与安装完成后,设置屏幕将不会再次出现,除非用户安装该应用程序。
I am making an android application but i can't figure out how i can make the setup screen show up only the first time. This is how the application is going to work: User launches the application after installation and is being shown the welcome/setup screen. And once the user is done with the setup, the setup screens will never appear again unless the user reinstalls the application.
我怎样才能做到这一点??? 请帮助和感谢这么多提前!
How can i make this happen??? Please help and thanks SO much in advance!
推荐答案
使用共享preferences
来检验其是否首次启动与否。
Use SharedPreferences
to test whether its the first start or not.
注:以下code未测试
Note: The below code was not tested.
在您的onCreate(或徘徊无论你想要做取决于第一次启动或没有的东西),添加
In your onCreate (or whereever you want to do things depending on first start or not), add
// here goes standard code
SharedPreferences pref = getSharedPreferences("mypref", MODE_PRIVATE);
if(pref.getBoolean("firststart", true)){
// update sharedpreference - another start wont be the first
SharedPreferences.Editor editor = pref.edit();
editor.putBoolean("firststart", false);
editor.commit(); // apply changes
// first start, show your dialog | first-run code goes here
}
// here goes standard code
这篇关于显示设置屏幕仅在Android的首次发射的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!