location-services

Turn GPS on programmatically like Ola Cabs Android app

风流意气都作罢 提交于 2019-12-03 09:48:08
问题 I am working on an application and need to integrate GPS location. I want to switch the GPS on programmatically. The condition is: I don't want to send the user to the Setting panel to enable it. I want to enable it forcefully or a single prompt will work (similar to the Ola Cabs Android app). A lot of questions are for this on this site but everyone is looking for the similar functionality like Ola Cabs app. So I have started this thread so that it can be clear for all of us. 回答1: Here is my

Turn GPS on programmatically like Ola Cabs Android app

孤街浪徒 提交于 2019-12-03 00:21:35
I am working on an application and need to integrate GPS location. I want to switch the GPS on programmatically. The condition is: I don't want to send the user to the Setting panel to enable it. I want to enable it forcefully or a single prompt will work (similar to the Ola Cabs Android app). A lot of questions are for this on this site but everyone is looking for the similar functionality like Ola Cabs app. So I have started this thread so that it can be clear for all of us. Here is my 100% working code first add this dependencie compile 'com.google.android.gms:play-services:9.2.1' to your

Found an error that GoogleApiClient is not connected yet

我与影子孤独终老i 提交于 2019-12-02 14:36:16
问题 private final static int CONNECTION_FAILURE_RESOLUTION_REQUEST = 9000; private double currentLatitude; private double currentLongitude; private GoogleApiClient mGoogleApiClient; private LocationRequest mLocationRequest; Button btn_start; TextView txt_refersh; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_demo); btn_start = (Button) findViewById(R.id.btn_start); txt_refersh = (TextView) findViewById(R.id.txt

startMonitoringSignificantLocationChanges not working in swift

本秂侑毒 提交于 2019-11-30 13:46:13
I'd added CLLocationManager in my app using Swift in the AppDelegate file. In the Appdelegate.swift file, import CoreLocation @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate, CLLocationManagerDelegate { var locationManager: CLLocationManager! In the didbecomeActive method: func applicationDidBecomeActive(application: UIApplication) { if((locationManager) != nil) { locationManager.stopMonitoringSignificantLocationChanges() locationManager.delegate = nil locationManager = nil } locationManager = CLLocationManager() locationManager.delegate = self locationManager

startMonitoringSignificantLocationChanges not working in swift

折月煮酒 提交于 2019-11-29 19:52:07
问题 I'd added CLLocationManager in my app using Swift in the AppDelegate file. In the Appdelegate.swift file, import CoreLocation @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate, CLLocationManagerDelegate { var locationManager: CLLocationManager! In the didbecomeActive method: func applicationDidBecomeActive(application: UIApplication) { if((locationManager) != nil) { locationManager.stopMonitoringSignificantLocationChanges() locationManager.delegate = nil locationManager

How to open Location services screen from setting screen?

╄→尐↘猪︶ㄣ 提交于 2019-11-28 04:54:58
I want to open location service screen programmatically to turn on service. Location services App-Prefs:root=Privacy&path=LOCATION worked for me. When I tested on a device and not a simulator. I won't list the things I tried that did not work, it's a long list. Usage example that assumes either location services are disabled or permission is denied or not determined: if !CLLocationManager.locationServicesEnabled() { if let url = URL(string: "App-Prefs:root=Privacy&path=LOCATION") { // If general location settings are disabled then open general location settings UIApplication.shared.openURL(url

Enable GPS programmatically Android (without navigating to the location settings)

微笑、不失礼 提交于 2019-11-27 20:39:49
How to enable GPS programmatically, as it does happen in the official Google Maps app by just clicking on the 'turn on' option on the pop up screen (without navigating to location settings)? The Google Maps app is using what is now available to us as SettingsApi the Play Services SDK. You can use SettingsApi to inquire as to whether your desired LocationRequest can be fulfilled with whatever location providers are enabled. If it cannot be fulfilled, and Play Services thinks that the user can change this, you can ask for the dialog that you see Maps display pop up. Using SettingsApi is not

How to enable Location access programmatically in android?

北战南征 提交于 2019-11-27 18:10:21
I am working on map related android application and I need to check location access enable or not in client side development if location services is not enable show the dialog prompt. How to enable "Location access" Programmatically in android? Gautam Use below code to check. If it is disabled, dialog box will be generated public void statusCheck() { final LocationManager manager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); if (!manager.isProviderEnabled(LocationManager.GPS_PROVIDER)) { buildAlertMessageNoGps(); } } private void buildAlertMessageNoGps() { final AlertDialog

Android: Google Maps location with low battery usage

我与影子孤独终老i 提交于 2019-11-27 03:26:10
My app is currently using Maps by Google Play Services speficying: mMap.setMyLocationEnabled(true); I realize each time I am displaying the map in my app: the location is indicated on the map by a blue dot a location icon is displaying in the top bar if I go into Settings/Location of the phone, my app is reported as "High battery use" However, I can see there are apps that use Maps and still show the location blue dot, but the location icon doesn't appear in top bar and their battery usage is low. My app currently grants both permissions: android.permission.ACCESS_COARSE_LOCATION android

How to open Location services screen from setting screen?

江枫思渺然 提交于 2019-11-27 00:27:31
问题 I want to open location service screen programmatically to turn on service. 回答1: Location services App-Prefs:root=Privacy&path=LOCATION worked for me. When I tested on a device and not a simulator. I won't list the things I tried that did not work, it's a long list. Usage example that assumes either location services are disabled or permission is denied or not determined: if !CLLocationManager.locationServicesEnabled() { if let url = URL(string: "App-Prefs:root=Privacy&path=LOCATION") { // If