有沒有辦法知道用戶使用該應用的時間? 基本上我想做一些東西后3使用,5用途等......我怎麼能把它關閉後的這種信息?確定應用的使用次數 - Android
0
A
回答
2
你可以保存在首選項。以下代碼打開首選項,獲取存儲在其中的次數,並將其增加。
SharedPreferences preferences = getPreferences(MODE_PRIVATE);
int times = preferences.getInt("openKey", 0);
preferences.edit().putInt("openKey", times+1).commit();
您可以在您的activity的onCreate方法中調用此代碼。
1
您可以使用SharedPreferences對象來存儲和獲取有關您的應用程序的任意信息。
使用Context.getSharedPreferences方法獲取此對象的實例。
編輯使用edit方法得到editor。完成後請不要忘記撥打commit。
重要提示:如果用戶卸載應用程序的首選項走開(只是要記住....)
0
如何將它保存在某個地方?像在Database,SharedPreference或XML-File?
相關問題
- 1. 確定android應用是否是第一次使用
- 2. 確定iPhone應用程序的第一次使用
- 3. Android - 確定手指觸摸的次數
- 4. 使用KBDLLHOOKSTRUCT確定第一次按鍵
- 5. Android:確定應用程序使用情況
- 6. 使用gnuplot確定二次方程的係數
- 7. 使用數據點確定二次方程的a,b,c
- 8. Excel VBA:使用命名範圍確定上次使用的行
- 9. Android RenderScript使用不確定的元素
- 10. 重複應用函數特定次數
- 11. Android:應用程序啓動次數
- 12. 如何確定第一次安裝或使用應用程序的日期?
- 13. 確定SOA應用程序中的線程數(使用Servlet)
- 14. Android的 - 確定調用
- 15. Android首次應用教程
- 16. Android應用安裝兩次
- 17. 確定Android上次用戶活動以來的時間
- 18. 確定使用數據源
- 19. 如何確定用戶是第一次運行應用程序?
- 20. 如何確定用戶正在使用的應用程序(在android中)?
- 21. 確定當我的應用程序運行的第一次
- 22. 如何確定應用是否在Android手機上使用特定傳感器?
- 23. 使用Android手機確定北向
- 24. gmail應用中用於不確定進度條的樣式android
- 25. 確定安裝的應用程序在Android中使用的權限列表
- 26. Android確定是否應使用多片段佈局
- 27. 使用固定次數的ng-repeat
- 28. 確定上次應用程序池回收的時間
- 29. 多次應用綁定的正確方法
- 30. 確定應用程序是否是第一次使用Titanium安裝