Java tutorial
//package com.java2s; //License from project: Apache License 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 receive, String action) { IntentFilter filter = new IntentFilter(action); LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context); lbm.registerReceiver(receive, filter); } public static void registerReceiver(Context context, BroadcastReceiver receive, String action) { IntentFilter filter = new IntentFilter(action); context.registerReceiver(receive, filter); } }