2

我想在 android 应用程序中获取其他应用程序的最后打开和使用日期...

有人可以帮忙吗?

4

2 回答 2

1

每次打开应用程序SharedPreferance时保存日期,但在保存之前,只需阅读上一次保存的日期,因此现在每次用户打开应用程序时都保存。

于 2012-11-03T04:33:15.303 回答
0

Just save the last opened date if you want time then date and time both. use SharedPreference to store. The date and time will be stored in milliseconds. Then when you open your application you can retrieve that. Other alternative is to use SQLite Database. Store the last opened date in database. By single row you can work here by upgrading the database everytime you open the application.

It will work like blow example.

@Override
public void onResume() {
Editor e = PreferenceManager.getDefaultSharedPreferences(this).edit();
e.putString("last_activity", getClass().getSimpleName());
e.commit();

super.onResume();
}
于 2012-11-03T04:43:36.210 回答