android-location

Android get location is null after phone reboot

空扰寡人 提交于 2019-12-24 10:49:11
问题 In my app im getting the phone's location via this function, but when I restart the phone and start the app I get null from this method. Is there something that im missing or doing wrong? What should I do to fix this issue? Here is the function im using: public void getAddress() { Log.v("--", "get address 1"); boolean isGPSProviderEnabled = locationManager .isProviderEnabled(LocationManager.GPS_PROVIDER); boolean network_enabled = locationManager .isProviderEnabled(LocationManager.NETWORK

map.setMyLocationEnabled(true); is not working

耗尽温柔 提交于 2019-12-24 07:23:08
问题 I have just started working on a android project and is using the Google Map API. I am able to fetch the map on my app but when i try to enable the current location with map.setMyLocationEnabled(true); , the app says unfortunately app has stopped working. When I removed the line map.setMyLocationEnabled(true); then it worked fine. Can anyone please help me to get the current location button enabled. 回答1: If you are using android 6.0 or above, you should: Make sure you added ACCESS_COARSE

Android LocationClient mock location not set

我的未来我决定 提交于 2019-12-24 00:58:05
问题 I'm trying to mock locations using the Play Services LocationClient . I have: Added the ACCESS_MOCK_LOCATION permission. Called setMockMode(true) on my LocationClient Called setMockLocation(Location) However, when I call getLastLocation() , I always get null . No updates are pushed to the LocationListener , and the null never changes. 来源: https://stackoverflow.com/questions/24690209/android-locationclient-mock-location-not-set

addProximityAlert works initially

梦想与她 提交于 2019-12-23 22:52:45
问题 I create a number of ProximityAlerts. It seems only the first works and sometime the second. They also seem to expire. I call this method to create a ProximityAlert: public boolean addProximityAlert(int id) { locationManager.addProximityAlert( latitude, longitude, POINT_RADIUS, PROX_ALERT_EXPIRATION, getPendingIntent(id) ); registerReceiver(new ProximityIntentReceiver(), getIntentFilter(id)); return true; } private PendingIntent getPendingIntent(int id) { Intent intent = new Intent(PROX_ALERT

How to set the location manually in Android Studio emulator

[亡魂溺海] 提交于 2019-12-23 11:51:25
问题 I have a project in which I need to get the location as India. But in my emulator I am not getting the location. I need to get the location as India when I take the google maps from my emulator, it is showing the current location in middle of the sea. API level I am using is 27. Emulator I use is Nexus 5x. how to get the current position in this Emulator and also manually. I tried to edit the location in Emulator and tried to give the latitude and longitude but it is not working. 回答1: First

Android 10 (Q) ACCESS_BACKGROUND_LOCATION permission

情到浓时终转凉″ 提交于 2019-12-23 04:55:57
问题 I need the user to check and set permission to ACCESS_BACKGROUND_LOCATION ("Allow all the time") without the option to "Allow only while using the app". My GPS Tracking app needs to continue accessing location even when the application is minimised. I have already permissions working for ACCESS_FINE_LOCATION for Android 9. AndroidManifest.xml---------------------------------------------------> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android

ACTION_LOCATION_SOURCE_SETTINGS : cannot be resolved or is not a field

不问归期 提交于 2019-12-23 03:45:15
问题 I'm calling ACTION_LOCATION_SOURCE_SETTINGS via Intent.its is showing cannot be resolved or is not a field caused while importing Project from outside. What should i do now ? Intent viewIntent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); startActivity(viewIntent); 回答1: Try this.. I guess your import is wrong Use import android.provider.Settings; Or try like below. Intent viewIntent = new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS); startActivity(viewIntent);

Change fuse location setting while service is running

醉酒当歌 提交于 2019-12-23 03:01:44
问题 Hi I am integrating location service in my application. And for that I am using Google's fuse location service. My implementation is as follows : public class LocationNotifyService extends Service implements LocationListener, GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener { protected void createLocationRequest() { mLocationRequest = new LocationRequest(); mLocationRequest.setInterval(INTERVAL); mLocationRequest.setFastestInterval(FASTEST_INTERVAL);

Change fuse location setting while service is running

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-23 03:01:12
问题 Hi I am integrating location service in my application. And for that I am using Google's fuse location service. My implementation is as follows : public class LocationNotifyService extends Service implements LocationListener, GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener { protected void createLocationRequest() { mLocationRequest = new LocationRequest(); mLocationRequest.setInterval(INTERVAL); mLocationRequest.setFastestInterval(FASTEST_INTERVAL);

After enable gps from an app prompt how to refresh and get the current location?

别说谁变了你拦得住时间么 提交于 2019-12-22 10:46:21
问题 I am currently developing an Android app which prompts the user to enable GPS if it's not on and I have used Alert Dialog for this purpose. After I enable the GPS from settings and come back to my app by pressing back button, the toast message display 0.00,0.00. Although If I have my GPS on before running the app, the app properly displays my location. I want to know to which method to use for this refresh user location after enabling GPS purpose. Any relevant article would really help. This