android-location

Detect if “Bluetooth scanning” for location is turned on

折月煮酒 提交于 2020-12-01 10:49:19
问题 Since Android M it is possible to scan for Bluetooth devices in the background even if the global location is turned off if you have enabled the Bluetooth scanning option in location settings (see screenshot). In order to scan for BLE devices, the following conditions must be met: COARSE_LOCATION or FINE_LOCATION permission granted. And one of the following: Global Location selector enabled. Bluetooth scanning option enabled (see screenshot). I can check that the permission is granted and the

fusedLocationProviderClient.lastLocation.addOnSuccessListener always null

ⅰ亾dé卋堺 提交于 2020-07-05 07:08:50
问题 I just updated my Location API to use FusedLocationProviderClient but I am having this issue, when I turn off and on the GPS, I am always getting null location: val fusedLocationProviderClient = LocationServices.getFusedLocationProviderClient(callingActivity) fusedLocationProviderClient.flushLocations() getLocationRequest() checkLocationSettings(callingActivity, turnOnGpsRequestCode, callback) { // Location settings successful fusedLocationProviderClient.lastLocation .addOnSuccessListener

How can I get my current location in Android using GPS?

久未见 提交于 2020-06-29 03:52:46
问题 I want to get my current location in the form of an address by GPS. I am using the android studio. It is saying that my application stops working. What is the error in it? Can someone help me to get out of this, please? My Code in activity_main.xml file is <?xml version="1.0" encoding="utf-8"?> <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools

Android Google Places API - PlaceAutocompleteFragment clear button listener

99封情书 提交于 2020-05-25 04:51:05
问题 I am using Google Places API for Android - PlaceAutocompleteFragment API in my project to search locations, when user selects a location then get the records using location lat-long and display it to ListView. Now the problem is whenever user taps on clear button (X) of PlaceAutocompleteFragment I want clear ListView items for which I need to listen to clear button onClick? How to do that? Any help will be appreciated. autocompleteFragment.setOnPlaceSelectedListener(new PlaceSelectionListener

locationListener doesn't work after 30 seconds on foreground service

泪湿孤枕 提交于 2020-02-22 06:30:27
问题 I have created a service which finds and then stores the user's coordinates in an SQLite database. public class GPS_Service extends Service { DatabaseHelper myDb; private LocationListener locationListener; private LocationManager locationManager; private String latitude, longitude; @Override public void onCreate() { super.onCreate(); myDb = new DatabaseHelper(this); } @SuppressLint("MissingPermission") @Override public int onStartCommand(Intent intent, int flags, int startId) { Intent

Android Fused Location Won't Deliver Periodic Updates

三世轮回 提交于 2020-01-24 09:45:30
问题 I want to get a hard location fix every certain minutes & a soft location fix every certain minutes and if user has moved more then certain meters. I been testing the logic with following piece of code walking (tried it with larger parameters as well while driving) but it doesn't really return me periodic location fixes. It would return a location fix right away when request starts then sometime return 1 location fix few minutes later that but then for up-to an hour it won't return a location

Best Practice to report user location continuously

给你一囗甜甜゛ 提交于 2020-01-20 15:33:09
问题 I'm designing an application where application in server side need to be continuously aware of user location. I'm thinking to create an Android service that run in the background and continuously query user location and send the result to an application in the backend server. However, I wonder if this is the best approach in terms of battery saving. For example, in iOS, there is something called "Significant-Change" to serve such purpose, does Android have similar thing. 回答1: I suggest to