Java Code Examples for android.content.Context#removeStickyBroadcast()

The following examples show how to use android.content.Context#removeStickyBroadcast() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DeviceTestUtils.java    From JobSchedulerCompat with MIT License 5 votes vote down vote up
@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);
    }
}
 
Example 2
Source File: FormEntryActivity.java    From commcare-android with Apache License 2.0 5 votes vote down vote up
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);
}