Pretend the device doesn’t have GPS

Asked

Viewed 76 times

2

I wonder if there is any way to "cheat" the device during debug by saying that it has no GPS. I don’t want to just disable, otherwise during development the GPS will be found.

I have the purpose of checking whether the device has the GPS present or not.

1 answer

1


I believe that by the debugger there is no pre-defined function for such a thing, but you can create a if and force her to be false, for example your code should be something like:

if (locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)){
    //Código com GPS
} else {
    //Código sem GPS
}

If you want to pretend that the GPS is not active do something like (apply the false):

if (false && locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)){
    //Código com GPS
} else {
    //Código sem GPS
}

Or you can simply comment on this line in the manifest:

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

And leave it at that:

<!-- uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" / -->
  • 1

    Thanks, I ended up forgetting that could deny the existence of the GPS in the device, thanks.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.