googlecodelabs / background-location-updates-android-o

Sample for background location changes in Android "O"
Other
81 stars 57 forks source link

Getting null LocationResult #5

Open 1priyank1 opened 6 years ago

1priyank1 commented 6 years ago

Getting LocationResult null in onReceive method of LocationUpdatesBroadcastReceiver

public class LocationUpdatesBroadcastReceiver extends BroadcastReceiver {
    private static final String TAG = "LUBroadcastReceiver";

    static final String ACTION_PROCESS_UPDATES =
            "com.google.android.gms.location.sample.backgroundlocationupdates.action" +
                    ".PROCESS_UPDATES";

    @Override
    public void onReceive(Context context, Intent intent) {        
        if (intent != null) {
            final String action = intent.getAction();
            if (ACTION_PROCESS_UPDATES.equals(action)) {
                LocationResult result = LocationResult.extractResult(intent);  //this result is null
mrinalTASKER commented 5 years ago

Have you resolved this issue because i'm also getting the same.

sivabe35 commented 5 years ago

Always getting the same null inLocationResult.extractResult(intent); Any Fix?

fatmaselin commented 5 years ago

have you resolved this issue ? or is there anyone any idea what can cause that ?

jeffrey-schmitz commented 5 years ago

I ran into this issue and was able to figure it out with trial and error. For me, it was because I was putting extras in the pending intent. Apparently, the locations are stored in the extras, and will not be written there if data already exists.

If you need to put extra data, you can throw it in the Data URI parameter, but it's pretty hacky. I'm hoping they solve this soon.

https://stackoverflow.com/questions/32893006/android-fusedlocationproviderapi-incoming-intent-has-no-locationresult-or-locat

fatmaselin commented 5 years ago

@parkskier426 thank you for your answer. I removed the put extras in the pending intent and this is the solution what I am looking for. thanks again.