nutella_eater
nutella_eater

Reputation: 3582

What is the better way to spread my locationUpdate through all application?

I want to broadcast my locationUpdate from GoogleApi (which is inside Service) to 3 different activities. I can implement a simple callback, but this way I can send my location only to one place.

@Override
    public void onLocationChanged(Location location) {
        mLocationCallback.handleNewLocation(location);
    }

On another hand I can create BroadCastReceiver:

private BroadcastReceiver receiver = new BroadcastReceiver() {

        @Override
        public void onReceive(Context context, Intent intent) {
            notifyListDataChanged();

        }
    };

but it looks ugly and takes a lot of time to code and maintain. Is there any other simple way to broadcast location updates from Service

Upvotes: 0

Views: 24

Answers (1)

GreyBeardedGeek
GreyBeardedGeek

Reputation: 30088

There are several message bus implementations for Android, including Otto, EventBus, and others. Any one of them should work for this.

Upvotes: 1

Related Questions