LunarS
LunarS

Reputation: 95

Communication between location service and Activity in Android?

there's a service class to update location, like lat and lng. What I want to do is pass the location to the Activity as soon as service getting result. Here are few tries I made:

  1. Broadcast receiver. It's very slow, I need to draw Activity based on location data, from self experience, it takes nearly half minute from service get last known location data to Activity receive broadcast signal.

  2. Callback. It's much better, but it's still hard to attain "as soon as".

Could you please give me some advice? Thank you.

Upvotes: 1

Views: 54

Answers (1)

Pawneshwer Gupta
Pawneshwer Gupta

Reputation: 2342

Best way is using interfaces. Because interface will notify main activity as soon as servicgot new result.

Upvotes: 1

Related Questions