Questions tagged [localbroadcastmanager]

143 questions
2
votes
1 answer

Avoid registering duplicate broadcast receivers in Android

I am trying to create my first Android app. I would like a main-thread Activity (in my case: an ActionBarActivity) to receive notification of an event from a background Activity (in my case: an IntentService). I've read that using broadcasts should…
2
votes
1 answer

Why and when to use LocalBroadcastManager?

I have a gone through couple of LocalBroadcastManager Android tutorials but could not find actual use of it and why to use it?
VVB
  • 7,363
  • 7
  • 49
  • 83
2
votes
1 answer

Compare performance of using LocalBroadcastManager and Otto

I'm trying to compare performance of using LocalBroadcastManager and Otto in Android. As I know, Otto is using annotation and Java reflection, so it may have some impacts on performance. Can someone suggest me something to do to measure performance…
congtrungvnit
  • 635
  • 1
  • 10
  • 16
2
votes
1 answer

BroadcastReceiver not showing any Log from onReceive

My service has function broadcaster = LocalBroadcastManager.getInstance(this); public void sendResult(String message) { Log.d("Service", "sendResult "+message); Intent intent = new Intent(); …
2
votes
1 answer

Why does LocalBroadcastManager.getInstance(Context context) require context as a parameter?

If I am able to register a receiver like so: LocalBroadcastManager.getInstance(this).registerReceiver(mMessageReceiver, new IntentFilter("myStringFilter")); and send out a broadcast like so: Intent intent = new…
Adam Johns
  • 35,397
  • 25
  • 123
  • 176
2
votes
2 answers

Does LocalBroadcastManager deliver events in the order in which the events wer sent?

I have an activity A and a service S. They commute via LocalBroadcastManager. If S calls sendBroadcast twice with two messages M1 and M2 in order, will A get M1 before M2? Thanks,
Joe C
  • 2,757
  • 2
  • 26
  • 46
2
votes
1 answer

Why the receiver defined in manifest is not receiving broadcasts when used with LocalBroadcastManager?

Few days ago I read that there is a better mechanism for sending broadcasts within single application - the LocalBroadcastManager. It works well (just like standard broadcasts..). However, yesterday I've found out that it cannot send broadcasts to…
2
votes
2 answers

Does the LocalBroadcastManager depend on app package names?

I'm creating an app using the new Android build system, and using a LocalBroadcastManager to fire notifications from an IntentService back to an Activity. I've defined the following product flavours as part of the build for 3 separate…
marcus.ramsden
  • 2,633
  • 1
  • 22
  • 33
2
votes
1 answer

BroadcastReceiver onReceive() not working

I don't understand why the onReceive method is never called. I've followed all the examples online, and I've looked through many similar questions on this site. Any ideas? Have I missed something? public class MainActivity extends Activity { …
2
votes
1 answer

LocalBroadcastReceiver doesn't work from inside a thread

I am building a simple chat application. When I receive a message, I sent a broadcast message. As this is run inside a thread started by a service, I pass the context to the thread. MyConnection is a class extending thread. @Override public void…
1
vote
1 answer

Fatal Exception: android.app.RemoteServiceException can't deliver broadcast

I am receiving Fatal Exception: android.app.RemoteServiceException can't deliver broadcast in my app. I have broadcast receiver set in my activity. It is registered as val filter = IntentFilter(Intent.ACTION_BATTERY_CHANGED) val receiver =…
Anju
  • 9,379
  • 14
  • 55
  • 94
1
vote
1 answer

Android correct place to intialize LocalBroadcastReceiver for an activity

I have an android activity that has BroadcastReceiver as below. @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); …
1
vote
1 answer

LocalBroadcastManager not found in androidx.appcompat:appcompat:1.1.0 but available in 1.0.0

I just migrated to androidx via the option Refactor -> Move to Androidx option in Android Studio. By default the build.gradle file was using: implementation 'androidx.appcompat:appcompat:1.0.0' I am using LocalBroadcastManager in many places in the…
SayantanRC
  • 799
  • 7
  • 23
1
vote
3 answers

Android Studio 3.5: not able to resolve LocalBroadcastManager

We are trying implement LocalBroadcastManager in our Android app but facing "Cannot resolve" error. This is the object we need - https://developer.android.com/reference/android/support/v4/content/LocalBroadcastManager Included the library in app…
Krishnan V S
  • 1,124
  • 1
  • 13
  • 31
1
vote
1 answer

Invoking a method in a fragment through a LocalBroadcastManager

I'm building an app with 2 fragments. 1st Fragment: ImageView and 2 TextViews 2nd Fragment: 2 EditTexts and 3 Buttons In the 2nd Fragment, I have a "Save" Button. In the onClick of this button, I am trying to send a local…
1 2
3
9 10