friend
我在这里很新,对于 Android 也是如此。我想知道是否可以每 5 -10 分钟获得一次 Wifi 信号,我听说我们可以使用广播接收器,但我不知道是否可以每 5 或 10 分钟刷新一次
谢谢
最佳答案
是的,你可以。
AlarmManager service = (AlarmManager) context
.getSystemService(Context.ALARM_SERVICE);
Intent i = new Intent(context, StatusQueryServiceStartReceiver.class);
// Schedule the alarm!If there is already an alarm scheduled for the same IntentSender, it will first be canceled.
PendingIntent pending = PendingIntent.getBroadcast(context, 0, i,
PendingIntent.FLAG_CANCEL_CURRENT);
// InexactRepeating allows Android to optimize the energy consumption
service.setInexactRepeating(AlarmManager.RTC_WAKEUP,
0,//cal.getTimeInMillis(),
REPEAT_TIME, pending);
// service.setRepeating(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(),
// REPEAT_TIME, pending);
StatusQueryServiceStartReceiver 是一个广播接收器
关于android - Broadcast Receiver 每 5 分钟获取一次 wifi 信号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20758181/