朋友
我在这里很新,对android也是如此。我想知道是否有可能每5-10分钟获得一次Wifi信号,我听说我们可以使用广播接收器,但我不知道是否可以每5或10分钟刷新一次。
谢谢
发布于 2013-12-24 09:33:21
您有两个选项,您可以体验网络的抽象状态,以获取信息,如果您已经连接或没有连接,如果它是移动的或WiFi使用ConnectivityManager,详细描述在这个android 文章中。
或者您可以使用WifiManager,这允许您:
对于您将不得不请求的部分操作
发布于 2013-12-24 09:28:39
可以,停那儿吧。
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是一个广播接收器
https://stackoverflow.com/questions/20758181
复制相似问题