Android的开放说明在应用程序第一次是什么时候? [英] Android instructions when open the application at first time?

查看:151
本文介绍了Android的开放说明在应用程序第一次是什么时候?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你知道这个

嗯,我想创造一些这样的画面。当我打开的第一次,我想在应用程序中打开此屏幕显示上下文。怎么可能?我不知道这种类型的事情有什么搜索。

解决方案

  @覆盖
公共无效的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;
}

这篇关于Android的开放说明在应用程序第一次是什么时候?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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