background-location-updates-android-o icon indicating copy to clipboard operation
background-location-updates-android-o copied to clipboard

Getting null LocationResult

Open 1priyank1 opened this issue 7 years ago • 5 comments

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

1priyank1 avatar Jun 19 '18 10:06 1priyank1

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

mrinalTASKER avatar Nov 19 '18 06:11 mrinalTASKER

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

sivabe35 avatar Nov 29 '18 10:11 sivabe35

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

fatmaselin avatar May 15 '19 11:05 fatmaselin

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

jeffrey-schmitz avatar May 16 '19 19:05 jeffrey-schmitz

@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.

fatmaselin avatar May 16 '19 22:05 fatmaselin