I was using Context.registerReceiver(), Context.sendBroadcast(Intent) , and Context.unregisterReceiver()
but when I saw the class LocalBroadcastManag
LocalBroadcastManager is as its name says, an implementation of the broadcast methods that are only available to your app. This has some benefits, with the biggest being safety, one less hole to watch out for. In terms of implementation, there are a few things to keep in mind:
LocalBroadcastManager.getInstance([CONTEXT]) where [CONTEXT] is a subclass of the Context class, such as Activity.So this class is not the same as Context, it is simply a very specific, app-only implementation of Context's receiver/broadcast methods. You should use it when there is absolutely no point for your listener to listen on global (system-wide) broadcasts and when your broadcast does not need to target anything outside your app.