android-location

How to time out GPS signal acquisition

北城余情 提交于 2019-12-18 00:49:48
问题 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?

Location Alarm for Android?

一世执手 提交于 2019-12-17 22:57:04
问题 When starting my app, several POI coordinates shall be added to the Android System. Some hours later, my app is closed and the user walks close to one of the POI he shall get notified e.g. through a status message. Is this the right approach for my scenario? Are there more things available in Android to achieve this? public void addProximityAlert (double latitude, double longitude, float radius, long expiration, PendingIntent intent) 回答1: Yes, you would use LocationManager and

Comparing two locations using their Longitude and Latitude

半腔热情 提交于 2019-12-17 10:34:41
问题 Hi i need to cal an event at onchangelocation(), by comparing current latitude and longitude with some saved latitude and longitude but i m getting an error. eclipse is not recognizing key word distance, and for correction error it is giving hint to crate method "distance" having 4 parameter ... how to fix it??? or some other way to do same work??? thanks and regards. code is attached below @Override public void onLocationChanged(Location location) { double currentLat=location.getLatitude();

Finding current location of the user in Android

和自甴很熟 提交于 2019-12-17 06:57:14
问题 I am new to Android and I am trying to develop an Android app which shows current location of the user. I am using Genymotion. Now I am using mLocation=LocationServices.FusedLocationApi.getLastLocation(mGoogleClient); to get the last location of the device. The thing is I wanted to get the current location but with this I get mlocation as not null that's fine. But in the map it shows last location of the device always not the current location. code snippet @Override public void onConnected

BroadcastReceiver for location

北城余情 提交于 2019-12-17 04:57:22
问题 I know BroadcastReceiver watches for text, phone events, etc... but can you run LocationServices as a service and event based on Location? For example, you are near a certain GPS point and the phone notifies you. 回答1: I think what you are looking for is something like this. There is a version of LocationManager.requestLocationUpdates() that takes a PendingIntent as a parameter, and this Intent could be used to fire a BroadcastReceiver . This code will register a custom broadcast to fire with

Why don't I get proximity alterts even though I've registered alerts?

耗尽温柔 提交于 2019-12-14 02:37:33
问题 I'm trying to simply set a proximity later for an area an for testing, I simply added this to the onCreate method of my main activity. public void onCreate(Bundle bndBundle) { IntentFilter filter = new IntentFilter(WidgetService.ACTION_STOP_PROXIMITY); registerReceiver(new ProximityIntentReceiver(), filter); LocationManager locManager = (LocationManager) this.getSystemService(LOCATION_SERVICE); Intent ittIntent = new Intent(this, ProximityIntentReceiver.class); ittIntent.putExtra

Localization of android application. One string resources for several countries

本小妞迷上赌 提交于 2019-12-13 20:18:38
问题 I have such a question: I have an Login/Registration Activity which is by default is using Russian version of strings.xml. So when user is entering application - he sees text in Russian language. But on that activity there is a button to choose another language. When he clicks that button - I open another activity in which he can choose which language to use (English/Spanish/German/etc). When he chooses a language (let's say German). How can I from this point in time, show to the user text

How to return value on GoogleApiClient onConnected()?

前提是你 提交于 2019-12-13 07:59:49
问题 I am using GoogleApiClient to get user location. I created a singleton class to get user location. Here is that class: public class LocationUtils { private static LocationUtils locationUtils; private GoogleApiClient googleApiClient; public static LocationUtils getInstance() { if(locationUtils == null) locationUtils = new LocationUtils(); return locationUtils; } private LocationUtils() {} public Location getLocation(Context context){ final Location[] location = {null}; googleApiClient = new

How can I request “High Accuracy” Location with the new SettingsApi on GooglePlayServices?

浪子不回头ぞ 提交于 2019-12-13 07:04:57
问题 I'm trying to use the new SettingsApi (https://developer.android.com/reference/com/google/android/gms/location/SettingsApi.html) from GooglePlayServices to detect the need for changes on users settings without exiting the app. My problem is that the dialog appears, but it only says it will require the Wifi and internet to access location. I also want it to request the GPS (this, is the High Accuracy mode or the device only mode). My code for getting the LocationSettingsRequest: public static

Oreo: how to catch location update from the background?

五迷三道 提交于 2019-12-13 06:30:54
问题 I migrate my app to oreo (as it's requiered by google play now), and i have now an error when i start my phone : Not allowed to start service Intent My app is listening in background any location update and send periodically those grabbed locations to a server. for this i do : in AndroidManifest.xml <receiver android:name="com.myapp.StartServiceBroadcastReceiver"> <intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED" /> </intent-filter> </receiver> in the