android-location

how to get Location object every 10 minutes in android

亡梦爱人 提交于 2019-12-13 04:24:17
问题 please someone give me a code can recover the GPS position or every n minutes, I tested several code but no result Please someone give me a tutorial or a small program for that, I'm really stuck public final class TrackListener implements LocationListener { private final Context mContext; public boolean isGPSEnabled = false; boolean isNetworkEnabled = false; public boolean canGetLocation = false; Location location; // location double latitude; // latitude double longitude; // longitude // The

Localization is returning null. What is wrong with the code?

女生的网名这么多〃 提交于 2019-12-13 04:14:29
问题 double longitude = 0; double latitude = 0; try { LocationManager lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE); Location location = lm.getLastKnownLocation(LocationManager.GPS_PROVIDER); longitude = location.getLongitude(); latitude = location.getLatitude(); } catch (Exception e1) { // TODO Auto-generated catch block e1.printStackTrace(); } In this code, the latitude and longitude is returning null.I want to get location without using internet. 回答1: There nothing wrong

How to make anything when my geolocation is changed?

烈酒焚心 提交于 2019-12-13 03:54:05
问题 I want to make some action, i.e. show dialog with text 'im here' every time when my geolocation will be changed. I'm using MyLocationOverlay to draw a dot on my location on the Google Maps's mapview. How can I achieve that? 回答1: Below is the location listener class - private MyOverLay draw = new MyOverLay(); class MyLocationListener_gps implements LocationListener { public void onLocationChanged(Location location) { clat = location.getLatitude(); clon = location.getLongitude(); GeoPoint

How to get real time current location update as we walk

雨燕双飞 提交于 2019-12-13 03:48:24
问题 I want to discuss if there is possibility of getting real time current location update as we move, I tried with FusedLocationProviderClient to request for current location update every 2 minutes What can we do to achieve this, implement detectActivity for walk and request current location update every 2 minutes or less in it? or there is on location change listener thing in FusedLocationProviderClient? so that we can listen for if there is change in location and get latlng in real time and

How to get longitude and latitude in Android

大憨熊 提交于 2019-12-12 16:06:45
问题 I want to find the longitude and latitude of my current location, but I keep get NULL . double lat = loc.getLatitude(); //Cause the result is null, so can't know longitude and latitude double lng = loc.getLongitude(); LocationManager locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE); String provider = LocationManager.GPS_PROVIDER; Location location = locationManager.getLastKnownLocation(provider); //result is null! This is the code to get the GPS status. It

How to give option for enable GPS

醉酒当歌 提交于 2019-12-12 06:49:25
问题 I want to show dialog box for turn on GPS when GPS is disable . See the image. When i click on YES then should be automatically turn on my GPS without going into setting. So , how can i enable GPS by select YES option ? 回答1: This is part of Google play service api since 7.0 called SettingsApi . Location settings - While the FusedLocationProviderApi combines multiple sensors to give you the optimal location, the accuracy of the location your app receives still depends greatly on the settings

How to return data in Android LocationListener

戏子无情 提交于 2019-12-12 04:58:46
问题 i want to build an app in which users can make foto which is tagged with the current location of the phone. So after making a foto, the user can save the picture by touching on the "save" button. If the button is touched the current location will be determined with my own LocationListener class. The Listener-class shows a Progressdialog and dismiss it, after a location is found. But now i want to know which i can return the location back to the calling Activity, because the Location listener

Update location every 5sec android

99封情书 提交于 2019-12-12 02:48:59
问题 Hi I want get user location for every 5sec and user can change that duration like 10sec, 15sec upto 30sec i have spinner to choose this option this is my request private static final LocationRequest REQUEST = LocationRequest.create() .setInterval(5000) // 5 seconds .setFastestInterval(16) // 16ms = 60fps .setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); this is initiate my start update private void startPeriodicUpdates(int intervel) { stopPeriodicUpdates(); REQUEST.setInterval(intervel);

Get the direction Android app user is headed on entering a geofence

给你一囗甜甜゛ 提交于 2019-12-12 01:22:04
问题 I'm playing around with geofences - what I'd like to do is when a geofence is fired, figure out which direction they're going. For example - let's ay I want to setup a geofence around a Culvers. While driving down the interstate heading north, when I enter the geofence I want to pop-up a notification that says "Culvers, take next exit on the right and make a right heading East". But if they're driving South on the interstate, it should pop-up and say "Culvers, take next exit on the right and

Android GooglePlay LocationClient is null, although initialized in onCreate()

南楼画角 提交于 2019-12-12 00:44:09
问题 I am working with the Google Play LocationClient. I have initialized it in onCreate() as stated in the docs: mLocationClient = new LocationClient(this, this, this); and I am doing a connect in onStart() mLocationClient.connect(); It works fine in my Android phone, but in the Developers Console I see that a NullPointerException is happening in the connect() line. How can this happen? 回答1: That is probably because the device that cause the NPE does not have Google Play Service or is not up to