register Local Receiver with IntentFilter - Android android.content

Android examples for android.content:Intent

Description

register Local Receiver with IntentFilter

Demo Code

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.IntentFilter;
import android.support.v4.content.LocalBroadcastManager;

public class Main {

  public static void registerLocalReceiver(Context context, BroadcastReceiver receiver, IntentFilter intentFilter) {
    if (context == null) {
      return;// w  w w .  jav  a 2 s .  c o  m
    }

    LocalBroadcastManager manager = LocalBroadcastManager.getInstance(context);
    manager.registerReceiver(receiver, intentFilter);
  }

}

Related Tutorials