Example usage for android.content Intent FLAG_RECEIVER_REPLACE_PENDING

List of usage examples for android.content Intent FLAG_RECEIVER_REPLACE_PENDING

Introduction

In this page you can find the example usage for android.content Intent FLAG_RECEIVER_REPLACE_PENDING.

Prototype

int FLAG_RECEIVER_REPLACE_PENDING

To view the source code for android.content Intent FLAG_RECEIVER_REPLACE_PENDING.

Click Source Link

Document

If set, when sending a broadcast the new broadcast will replace any existing pending broadcast that matches it.

Usage

From source file:org.schabi.terminightor.NightKillerActivity.java

@Override
protected void onResume() {
    Intent intent = new Intent(this, this.getClass());
    intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING | Intent.FLAG_ACTIVITY_SINGLE_TOP);

    pendingIntent = PendingIntent.getActivity(this, SpecialPendingIds.NIGHT_KILLER_READ_NFC_TAG_ID, intent,
            PendingIntent.FLAG_CANCEL_CURRENT);
    IntentFilter[] intentFilters = new IntentFilter[] {};
    nfcAdapter.enableForegroundDispatch(this, pendingIntent, intentFilters, null);

    Handler handler = new Handler();
    handler.postDelayed(animRunnable, 500);
    hasStopped = false;//from   w  w w .j  a  v  a2  s .c o m

    super.onResume();
}

From source file:org.universAAL.android.services.MiddlewareService.java

private void notifyPercent() {
    // TODO use pending intent? isnt a single sticky intent always there with this already?
    Intent intent = new Intent(AppConstants.ACTION_UI_PROGRESS);
    intent.setFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING + Intent.FLAG_RECEIVER_REGISTERED_ONLY);
    intent.setPackage(getPackageName());
    sendBroadcast(intent);/*  w  ww  . ja  v a  2  s .c  o  m*/
}

From source file:com.mario22gmail.license.nfc_project.NavigationDrawerActivity.java

private void enableForegroundDispatchSystem() {

    Intent intent = new Intent(this, NavigationDrawerActivity.class)
            .addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);

    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, 0);

    IntentFilter[] intentFilters = new IntentFilter[] {};
    nfcAdapter.enableForegroundDispatch(this, pendingIntent, intentFilters, null);
}