I noticed that with the new update to google map, if you have GPS is off, then it warns you about the accuracy. Here is the new thing, if you hit OK then it enables the GPS for you. Which means it is programmatically enabling GPS as opposed to me going to Settings. I have Kitkat running on samsung S4
Does this means that there is an official way to enable GPS programatically?IF yes then how?
Thanks
Google Play service 7.0 and above have this feature.
In Google Play services 7.0, we’re introducing a standard mechanism to
check that the necessary location settings are enabled for a given
LocationRequest to succeed. If there are possible improvements, you
can display a one touch control for the user to change their settings
without leaving your app.
http://android-developers.blogspot.in/2015/03/google-play-services-70-places-everyone.html
Related
Recently my ola cabs application, after the latest update, asked for location permission at runtime. It did not open the location settings screen but just by clicking on yes, my location (GPS) of the device was turned on and the application proceeded without going to location settings or any settings screen. This feature was about to come in android M and is available on the MNC preview only, so I am guessing it cannot be used in devices at this point of time. So how is this application implementing this feature?
It is using SettingsApi in the Play Services SDK 7.0+, to display the location settings dialog.
I am working on an android application that uses geo location services, when the user accesses such service if location access is disabled on the device i want to call android native pop up that guides user to enabled location access. Is it possible to do this ?
I noticed there's even better way to achieve good location settings, without "guiding" user to turn them on, mentioned in this question:
Enabling Location with mode High Accuracy or Battery saving without user needing to visit Settings
Since Google Play Services 7.0 you can ask system to offer user turning the settings on with one touch. It's how Google Maps are doing it.
I'm working on a GPS game, similar to geocaching, which requires the devices accurate GPS cordinates.
I am using LocationClient and not LocationManager.
Early in testing, a friend pointed out that the location can be faked using free apps on the play store. A bit of research shows that without root, these apps require Mock Location to be enabled. So I started with a simple check to see if mock location was enabled, and if it was then the app would not allow the user to play until it is disabled.
This got me thinking though, users who are rooted could still fake their location without having mock location enabled, however most of these apps still have the MOCK_LOCATION permission regardless if the device is rooted or not. So I used a method that detects any apps that require Mock Location. The problem is, even on my non rooted Note 3, there appears to be several pre-installed apps that require Mock Location for some reason, which then prevents game play. So this solution wont work.
Is there any other way to check if a location might be faked using LocationClient?
In API 18+ you can use Location.isFromMockProvider to check if a particular location is mocked. This flag will be set to true if an app is providing mocked (fake) locations or if you are using a mock provider in your own app.
Of course, rooted phones can bypass this.
In your device, go to settings >> developer options >> allow mock locations
This option must be checked in you device that's why you are getting mock location updates. To stop receiving just uncheck it.
In your code, you can also set mLocationClinet.setMockMode(false); in your onCreate() method of Location tracking activity.
I hope it works :)
I've got two problems using the latest version (1.3.1) of the Genymotion emulator, related to the Google Play Services location APIs. More specifically:
1) The LocationClient only works (i.e. sends location events when I use the Genymotion GPS menu) when I request location updates with the PRIORITY_HIGH_ACCURACY flag. The two other LocationRequest modes, PRIORITY_BALANCED_POWER_ACCURACY and PRIORITY_LOW_POWER don't work.
2) Geofencing, on the other hand, doesn't work at all. When I add geofences via LocationClient.addGeofences(), the LocationClient.OnAddGeofencesResultListener callback returns the GEOFENCE_NOT_AVAILABLE status code.
Is anyone else experiencing the same issues? And does anyone have a workaround? For now, I am only testing my app's location services using the PRIORITY_HIGH_ACCURACY flag and geofencing on a real device.
I had the issue regarding geolocation a few days ago and contacted Genymotion about it. They said they do not currently support Geolocation features but may consider implementing them in the future.
I don't know the answer to your first question as I haven't had this problem.
I experience the same problem here. Using the latest (6.5.x) Google Play services Location API I get no location updates with Genymotion when using PRIORITY_BALANCED_POWER_ACCURACY.
This is when running on an S3 Android 4.3 image.
I have an app running on Android that uses only a webview to display a mobile web-application and at some point uses the device's GPS to obtain their position.
I have a custom ChromeWebClient etc and it obtains their position nicely except for on devices where the Power Saving Mode is enabled?
Is there anyway in the SDK/API for me to be able to determine if the user has this enabled and to advise them accordingly?
I can't find anything in the docs so i am assuming not but worth a shot,
Cheers,
Lee
After reeding the comments
In my experience Samsung, as well as HTC, is one of the manufacturers that modify Android OS in most unpredictable ways. They add new functions and modes, like 4G switching launcher widgets and "power saving mode". They modify permission requirements for documented SDK methods, i.e. to switch on bluetooth on a Samsung device your app needs to have and additional android.permission.BLUETOOTH permission, while stock Android only needs android.permission.BLUETOOTH_ADMIN. And there's more.
Long story short, as #RaghavSood pointed out, "power saving mode" is not an official AOSP feature and there are no ways to detect it via official SDK. There is a possible way how you can work around it though. I believe it is most likely that your app misbehaves in power saving mode because this mode turns off GPS. You can confirm that by configuring power saving mode in settings to disable GPS disabling(can't phrase this better, sorry) - first link from google with steps. Then test the app. Does it work? If yes, then you've rootcaused the problem and now your job is to let the user know that your app won't run without GPS. You can put some code into your app to detect if GPS service is enabled an show an alert dialog if it isn't. The code in your activity can look something like this:
LocationManager lm = getSystemService(Context.LOCATION_SERVICE);
if(!lm.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
//Show a notification prompting user to switch on GPS.
}
You can be even more elaborate and make your app detect device manufacturer to show a custom message on all Samsung devices.