Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[android] - use local broadcast receiver for telemetry (#7511)
Browse files Browse the repository at this point in the history
  • Loading branch information
tobrun committed Dec 21, 2016
1 parent e3fd2d8 commit 738cba3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
import android.Manifest;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.location.Location;
import android.location.LocationManager;
import android.support.annotation.NonNull;
import android.support.v4.content.ContextCompat;
import android.support.v4.content.LocalBroadcastManager;
import android.util.Log;

import com.mapbox.mapboxsdk.telemetry.TelemetryLocationReceiver;
Expand Down Expand Up @@ -138,10 +140,9 @@ public void onLocationChanged(Location location) {
listener.onLocationChanged(location);
}

// Update the Telemetry Receiver
Intent locIntent = new Intent(TelemetryLocationReceiver.INTENT_STRING);
Intent locIntent = new Intent();
locIntent.putExtra(LocationManager.KEY_LOCATION_CHANGED, location);
context.sendBroadcast(locIntent);
LocalBroadcastManager.getInstance(context).sendBroadcast(locIntent);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import android.os.AsyncTask;
import android.os.IBinder;
import android.support.annotation.Nullable;
import android.support.v4.content.LocalBroadcastManager;
import android.util.Log;

/**
Expand Down Expand Up @@ -52,13 +53,10 @@ public IBinder onBind(Intent intent) {
@Override
public void onCreate() {
super.onCreate();

Log.i(TAG, "onCreate() called");

// Enable Location Listening for lifecycle of app
IntentFilter filter = new IntentFilter(TelemetryLocationReceiver.INTENT_STRING);
telemetryLocationReceiver = new TelemetryLocationReceiver();
registerReceiver(telemetryLocationReceiver, filter);
LocalBroadcastManager.getInstance(getApplicationContext()).registerReceiver(
new TelemetryLocationReceiver(),
new IntentFilter(TelemetryLocationReceiver.INTENT_STRING)
);
}

/**
Expand Down

0 comments on commit 738cba3

Please sign in to comment.