如何在日期更改时注销用户
问题描述:
我正在开发一个应用程序,用户需要在更改日期时注销。正如我使用报警管理器注销用户,但我无法做到这一点。他们是否有机会使用日期注销用户。如何在日期更改时注销用户
的代码如下
AlarmManager alarmMgr = (AlarmManager)getSystemService(Context.ALARM_SERVICE);
Intent intent = new Intent(this, Login.class);
PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, intent, 0);
Calendar timeOff = Calendar.getInstance();
/* setting time */
timeOff.set(Calendar.HOUR_OF_DAY, 23);
timeOff.set(Calendar.MINUTE, 59);
timeOff.set(Calendar.SECOND, 0);
alarmMgr.setInexactRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,
SystemClock.elapsedRealtime() + AlarmManager.INTERVAL_DAY,
AlarmManager.INTERVAL_DAY, intent);
答
使用这个动作
final IntentFilter filter = new IntentFilter();
filter.addAction(Intent.ACTION_TIME_TICK);
/**eg
this.sysForbidenReceiver.checkTime(this);
this.registerReceiver(this.sysForbidenReceiver, filter);
**/
ü可以简单 –
https://developer.android.com/reference/android/content/Intent解释。 HTML#ACTION_TIME_TICK – sanemars