【发布时间】:2016-02-28 14:28:49
【问题描述】:
我有地理围栏 IntentService。在 GEOFENCE_ENTER 我创建广播接收器。但它没有动作。
如果我在 MainActivity 中创建它 - 一切都很好。但我不需要。
我不明白当我从服务创建接收器时会发生什么。
public class GeofenceTransitionsIntentService extends IntentService {
...
@Override
protected void onHandleIntent(Intent intent) {
...
if (geofenceTransition == Geofence.GEOFENCE_TRANSITION_ENTER) {
//Create WiFi scan receiver
WiFiScanReceiver wifiScan = new WiFiScanReceiver();
registerReceiver(wifiScan, new IntentFilter(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION));
//Scan
WifiManager wm = (WifiManager) getSystemService(Context.WIFI_SERVICE);
Boolean scanStarted = wm.startScan();
}
}
【问题讨论】:
标签: android android-intentservice android-broadcastreceiver