android-location

Android mock gps provider

不问归期 提交于 2019-11-29 11:13:42
My code snippet is: mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); if(mLocationManager.getProvider(LocationManager.GPS_PROVIDER) != null) { mLocationManager.removeTestProvider(LocationManager.GPS_PROVIDER); } mLocationManager.addTestProvider(LocationManager.GPS_PROVIDER, "requiresNetwork" == "", "requiresSatellite" == "", "requiresCell" == "", "hasMonetaryCost" == "", "supportsAltitude" == "", "supportsSpeed" == "", "supportsBearing" == "", android.location.Criteria.POWER_LOW, android.location.Criteria.ACCURACY_FINE); location = new Location(LocationManager

Does PRIORITY_BALANCED_POWER_ACCURACY exclude the GPS provider?

戏子无情 提交于 2019-11-29 08:45:49
Got this from How much accuracy does PRIORITY_BALANCED_POWER_ACCURACY give? The HIGH_ACCURACY mode use all location providers, However, it prioritize the location providers and include GPS along with location providers. The location accuracy is approximately within 10 meters of range. The BALANCED_POWER mode exclude GPS for its list of location providers, and use the other providers based including cell towers, wifi etc. In this case, the location accuracy is approximately 40 meters. The NO_POWER do not use any location provider, instead it is a passive mode of getting location from other apps

Android: Drag map while keeping marker at the center

China☆狼群 提交于 2019-11-29 04:08:56
I am currently getting Current Location of device (lat,lng) in MapActivity. Now , I want to let the user move the map, while keeping the marker at the center. This means that whenever the map is moved, current location will be updated. (Right?) I followed this How to move a map under a marker? and How to attach a flexible marker on map something like Uber and Lyft? but couldn't get my concept clear. Activity_map.xml (Here I have added ImageView) <RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent" xmlns:android="http://schemas.android.com/apk/res/android">

sending extra to requestLocationUpdates intentService breaks location updates

时光总嘲笑我的痴心妄想 提交于 2019-11-29 01:38:40
问题 I'm having trouble sending a string extra with my PendingIntent that I pass to LocationServices.FusedLocationApi.requestLocationUpdates(GoogleApiClient client, LocationRequest request, PendingIntent callbackIntent) . It appears that the username extra i'm putting onto the Intent is mangling the location that requestLocationUpdates is trying to hand off to my IntentService as intent.getParcelableExtra(FusedLocationProviderApi.KEY_LOCATION_CHANGED) returns null . EDIT I've tried making a User

How to time out GPS signal acquisition

纵饮孤独 提交于 2019-11-28 21:41:13
My app uses the LocationListener to get one position fix and then removeUpdates() once every minute (to conserve battery). The problem is that if a user moves inside then it will perpetually look for a signal, burning more battery. I was wondering if anyone knows of a public method within Location Manager I can use to removeUpdates if a signal isn't acquired within 15 seconds. I would then check for a position fix every five minutes until the user moves back outdoors. Does this make sense? Maybe there is a better method to timeout GPS signal acquisition? I have looked through the Location

How to get the coarse location using Wifi or GSM or GPS, whichever is available?

a 夏天 提交于 2019-11-28 20:43:26
My app only needs a coarse location service when started up. In detail, I need the app's rough location so as to provide the users with the shop info nearby. The location does NOT need to be updated constantly. In addition, coarse localization will be sufficient in this case. I wish the app to choose GSM, or wifi, or GPS automatically, whichever is available. The location service should also be one-time to save phone energy . How may I do that? I have tried using GPS separately. My problem is I don't know how to stop the constantly-refreshing-location feature of GPS. I don't know how to make

Minimal android foreground service killed on high-end phone

霸气de小男生 提交于 2019-11-28 16:19:18
问题 I'm trying to create an app that lets users log routes (locations/GPS). To ensure locations are logged even when the screen is off, I have created a foreground service for the location logging. I store the locations in a Room Database which is injected into my service using Dagger2 . However, this service is killed by Android which is, of course, not good. I could subscribe to low memory warnings but that doesn't solve the underlying problem of my service getting killed after ~30 minutes on a

Stop Location Listener in Android

坚强是说给别人听的谎言 提交于 2019-11-28 09:39:30
In my android app I need to get current GPS location of the user at the start of the application only if location has change from the previous location. But the problem is when I inside the application if location change ( ie If user was traveling while using the app) app is starting from the beginning. I need to stop location listener after getting user current location. removeUpdates method didn't work for me. Please help me on this issue. thanks in advance ! Shah mLocManager.removeUpdates(locationListenerObject); mLocManager = null; Call this inside your onLocationChange Method when lat and

LocationManager throws NullPointerExpection

守給你的承諾、 提交于 2019-11-28 06:40:51
问题 Please I have this code which has been working for me all this while, all of a sudden it is not working any more, it returns null pointer exception at double lat = (double) (lastKnownLocation.getLatitude());. I have set all required permission at the manifest file , but it seems not to work again. I think there must be a problem using the GPS provider now. latituteField = (TextView) findViewById(R.id.TextViewLatitudeValue); longitudeField = (TextView) findViewById(R.id.TextViewLongitudeValue)

Get GPS Location instantly via Android app

别等时光非礼了梦想. 提交于 2019-11-28 06:40:37
问题 all. I am writing an android app about GPS locations. I tried it on emulator and entered the latitude and longitude manually, and it worked fine. However, my problem is: on the real device, in debugging mode, to go the next class by using intent can only be achieved when location is changed. If I start the app directly, I can see the blinking GPS icon, but the app will only stay here, and won't start the next activity. It seems that the variables in the onLocationChanged() will never be