Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Runs when a GoogleApiClient object successfully connects.
- */
- @Override
- public void onConnected(Bundle connectionHint) {
- Intent mIntent = new Intent(context, LocationReceiver.class);
- PendingIntent mPendingIntent = PendingIntent.getBroadcast(context, 42, mIntent, PendingIntent.FLAG_CANCEL_CURRENT);
- LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient, mLocationRequest, mPendingIntent);
- }
- <receiver
- android:name=".LocationReceiver"
- android:enabled="true"
- android:exported="true" >
- <intent-filter>
- <action android:name="com.myapp.databerries.LOCATION_READY" />
- <category android:name="android.intent.category.DEFAULT" />
- </intent-filter>
- </receiver>
- public class LocationReceiver extends BroadcastReceiver {
- public LocationReceiver() {
- }
- @Override
- public void onReceive(Context context, Intent intent) {
- Bundle b = intent.getExtras();
- Location loc = (Location)b.get(android.location.LocationManager.KEY_LOCATION_CHANGED);
- if (loc != null)
- Log.d("hello", "location = " + loc.toString());
- else
- Log.d("hello", "location = null");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement