DanielH
DanielH

Reputation: 953

LocalBroadcastManager only with support library?

In my Android app I want to broadcast some notifications. In the MainActivity I register BroadcastReceiver which handles messages but as I understand it is not recommended to use global BroadcastReceiver if I do not want to send messages out of the app. Instead of this a LocalBroadcastManager or Handler should be used. In my case LocalBroadcastManager is more suitable but according to documentation it is part of a support library.

My app supports only Android 4 and 5 so I am not using support library. Is there a way how to use LocalBroadcastManager without support library? Thanks

Upvotes: 1

Views: 667

Answers (2)

SeungHoon Han
SeungHoon Han

Reputation: 1

Try using localbroadcastmanager Maven artifact. It doesn't need "support-v4".

implementation 'com.android.support:localbroadcastmanager:28.0.0'

Upvotes: 0

Blackbelt
Blackbelt

Reputation: 157447

My app supports only Android 4 and 5 so I am not using support library. Is there a way how to use LocalBroadcastManager without support library?

No there is not. As the ViewPager and another small amounts of Widget/Classes, LocalBroadcastManager is part only of the support library

Upvotes: 3

Related Questions