我的应用程序有一个子类广播接收器:
public class LocationBroadcastReceiver extends BroadcastReceiver {
LocationBroadcastReceiver.class.getSimpleName();
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(Constants.BROADCAST_LOCATION_ACTION)) {
Bundle extras = intent.getExtras();
Log.d(LOG_TAG, "BCAST LAT = " + extras.getDouble("LAT") + " LON = " + extras.getDouble("LON"));
}
}
在发送上述广播和日志消息的服务中生成日志消息。为发送的单个广播消息获取多个广播。
我使用以下方法动态注册接收器:
mLocateBcast = new LocationBroadcastReceiver();
IntentFilter locationFilter = new IntentFilter();
locationFilter.addAction(Constants.BROADCAST_LOCATION_ACTION);
LocalBroadcastManager.getInstance(mContext).registerReceiver(mLocateBcast,locationFilter);
我的清单中没有定义接收器。在之前的Android版本中,我收到了一个类似设置的广播。我错过了什么?
答案 0 :(得分:0)
使用Marshmallow时,无论是否存在实际的位置更改,当LocationRequest setInterval值到期时都会调用onLocationChanged回调。
不期待这种行为。