[英]How do I make the terms and conditions appear only when I log in to Google for the first time?
[英]Showing Terms and Conditions for first time in an android app
我正在開發一個 android 應用程序,其中第一個屏幕是啟動屏幕。 如果用戶是第一次使用(意味着剛剛安裝了應用程序),我必須顯示條款和條件,否則,我必須顯示登錄屏幕。
如何獲取應用程序打開的次數或首次打開應用程序的指示? 有沒有API
呢?
你不需要這個計數器:
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
if(!prefs.getBoolean(KEY_EULA_ACCEPTED, false)) {
showEula();
// Determine if EULA was accepted this time
prefs.edit().putBoolean(KEY_EULA_ACCEPTED, true).commit();
}
您可以使用SharedPreferences (教程)。
只需檢查某個值 onCreate()。 如果它不存在,做一些事情,然后設置值。 下一次,該值將在那里,您可以跳過它。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.