确定Android应用程序是否是第一次使用我目前正在开发一个Android应用程序。当应用程序第一次启动时,我需要做一些事情,即代码只在程序第一次启动时运行。
3 回答
青春有我
TA贡献1784条经验 获得超8个赞
final String PREFS_NAME = "MyPrefsFile";SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
if (settings.getBoolean("my_first_time", true)) {
//the app is being launched for first time, do something
Log.d("Comments", "First time");
// first time task
// record the fact that the app has been started at least once
settings.edit().putBoolean("my_first_time", false).commit(); }- 3 回答
- 0 关注
- 192 浏览
添加回答
举报
0/150
提交
取消
