【发布时间】:2015-10-25 16:27:50
【问题描述】:
清单:
<receiver android:name=".GpsLocationReceiver">
<intent-filter>
<action android:name="android.location.PROVIDERS_CHANGED" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
广播接收者:
public class GpsLocationReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Log.d(TAG, "onReceive...");
if(intent.getAction().matches("android.location.PROVIDERS_CHANGED")) {
Log.d(TAG, "GPS provider changed...");
EventBus.getDefault().postLocal(intent.getAction());
}
}
}:
【问题讨论】:
-
编辑
Log.d(TAG, "onReceive...");到这个 ->Log.d(TAG, intent.getAction();看看为什么会被调用两次 :) -
两次都一样:android.location.PROVIDERS_CHANGED