下面列出了android.content.Context#removeStickyBroadcast ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private void registerFormEntryReceiver() {
//BroadcastReceiver for:
// a) An unresolvable xpath expression encountered in PollSensorAction.onLocationChanged
// b) Checking if GPS services are not available
mLocationServiceIssueReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
context.removeStickyBroadcast(intent);
badLocationXpath = intent.getStringExtra(PollSensorAction.KEY_UNRESOLVED_XPATH);
locationRecieverErrorAction = intent.getAction();
}
};
IntentFilter filter = new IntentFilter();
filter.addAction(PollSensorAction.XPATH_ERROR_ACTION);
filter.addAction(GeoUtils.ACTION_CHECK_GPS_ENABLED);
registerReceiver(mLocationServiceIssueReceiver, filter);
}
@SuppressWarnings("deprecation")
public static void setStorageNotLow(Context context, boolean storageNotLow) {
Intent storageLowIntent = new Intent(Intent.ACTION_DEVICE_STORAGE_LOW);
if (storageNotLow) {
context.removeStickyBroadcast(storageLowIntent);
} else {
context.sendStickyBroadcast(storageLowIntent);
}
}