你知道这个
嗯,我想创造一些这样的画面。当我打开的第一次,我想在应用程序中打开此屏幕显示上下文。怎么可能?我不知道这种类型的事情有什么搜索。
解决方案 @覆盖
公共无效的onCreate(包savedInstanceState){
super.onCreate(savedInstanceState);
...
如果(isFirstTime()){
//你做什么时,打开应用程序第一次到这里
}
...
}
/ ***
*检查该应用程序运行的第一次,并在共享preferences写标志
* @返回true,如果第1次
* /
私人布尔isFirstTime()
{
共享preferences preferences = GET preferences(MODE_PRIVATE);
布尔ranBefore = preferences.getBoolean(RanBefore,假);
如果(!ranBefore){
// 第一次
共享preferences.Editor编辑器= preferences.edit();
editor.putBoolean(RanBefore,真正的);
editor.commit();
}
返回ranBefore!;
}
Do you know this
Well i want create something like this screen. When i open for the first time the application i want open this screen and display a context.. How is possible? I don't know what search for this type of thing..
解决方案@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
...
if (isFirstTime()) {
// What you do when the Application is Opened First time Goes here
}
...
}
/***
* Checks that application runs first time and write flag at SharedPreferences
* @return true if 1st time
*/
private boolean isFirstTime()
{
SharedPreferences preferences = getPreferences(MODE_PRIVATE);
boolean ranBefore = preferences.getBoolean("RanBefore", false);
if (!ranBefore) {
// first time
SharedPreferences.Editor editor = preferences.edit();
editor.putBoolean("RanBefore", true);
editor.commit();
}
return !ranBefore;
}
上一篇:活动开始左向右模式模式