locationmanager

Retrieving # of satellites used in gps fix from Android

雨燕双飞 提交于 2019-12-03 07:54:59
问题 I am trying to retrieve the # of satellites used in the GPS fix. I have implemented two different methods, as shown below: package ti.utils; import android.app.Activity; import android.content.Context; import android.location.GpsSatellite; import android.location.GpsStatus; import android.location.Location; import android.location.LocationListener; import android.location.LocationManager; import android.os.Bundle; public class Gps { private static final int TWO_MINUTES = 1000 * 60 * 2;

Starting LocationManager as Service Android

柔情痞子 提交于 2019-12-03 07:54:13
What I'm attempting to do is when receiving a c2dm message, start a service that asks for location for 'x' amount of time and then hands that location off to our server. The c2dm message starts the service correctly, and the GPS location turns on, but it never updates. It just sits there for the length of time I specify (currently 12 seconds) in the thread and does nothing. I'm using the exact same code somewhere else in my app (not as a service) and it works perfectly. What am I doing wrong? This starts the service when receiving a c2dm message. context.startService(new Intent(context,

Difference between LocationRequest setInterval (long millis) and LocationRequest setFastestInterval (long millis)

我们两清 提交于 2019-12-03 04:30:40
问题 I am writing my own background location updates for interval of every 5 minutes in android. I would like to know the difference between setInterval and setFastestInterval When I setInterval to 5 mins and setFastestInterval to 2 mins. The location update is called every 2 mins. I would like to know the difference. I couldn't understand what exactly is written in the developer page for this https://developer.android.com/reference/com/google/android/gms/location/LocationRequest.html Also: Is

current location is always null

匆匆过客 提交于 2019-12-03 00:50:09
I am trying to retrieve my current location on the button click in an editbox using gps or network..i have tried all possible methods which i found in tutorials and older posts....but my location is always null.. i am not getting where i am wrong.? i am testing it on real device having network but no internet/gprs... this is the code which i am using..i tried the same with GPS_PROVIDER as well ..please help me.. protected void showCurrentLocation() { geocoder = new Geocoder(this); locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); locationManager

requestLocationUpdates throws exception

一个人想着一个人 提交于 2019-12-02 21:26:25
问题 I am creating a service that periodically updates the position. but using the following code, it throws me: runException Can't create handler inside thread that has not called Looper.prepare() This code is running inside doInBackground of Async class in service private void UpdatePosition() { locManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE); Location location = locManager.getLastKnownLocation(LocationManager.GPS_PROVIDER); showPosition(location); locationListener = new

Retrieving # of satellites used in gps fix from Android

别说谁变了你拦得住时间么 提交于 2019-12-02 21:23:09
I am trying to retrieve the # of satellites used in the GPS fix. I have implemented two different methods, as shown below: package ti.utils; import android.app.Activity; import android.content.Context; import android.location.GpsSatellite; import android.location.GpsStatus; import android.location.Location; import android.location.LocationListener; import android.location.LocationManager; import android.os.Bundle; public class Gps { private static final int TWO_MINUTES = 1000 * 60 * 2; private static Location Location; public static int Satellites = -1; public static void StartTracking

Difference between LocationRequest setInterval (long millis) and LocationRequest setFastestInterval (long millis)

天涯浪子 提交于 2019-12-02 17:50:00
I am writing my own background location updates for interval of every 5 minutes in android. I would like to know the difference between setInterval and setFastestInterval When I setInterval to 5 mins and setFastestInterval to 2 mins. The location update is called every 2 mins. I would like to know the difference. I couldn't understand what exactly is written in the developer page for this https://developer.android.com/reference/com/google/android/gms/location/LocationRequest.html Also: Is there an inbuilt function to check the location updates only if the distances of the first update are more

How does getSystemService() work exactly?

旧街凉风 提交于 2019-12-02 16:47:06
At first glance in the code below the mLocationManager object should go out of scope after onCreate(...) is finished, and the expected behaviour is that onLocationChanged is never called or called a few times until the object is garbage collected. However the object returned by the getSystemService seems to be singleton which lives outside the scope of MainActivity (appropriately so since it is a system service :) ) After taking a heap dump and going through it with the Eclipse Memory Analyzer it seems that ContextImpl keeps a reference to a LocationManager instance. In the memory dump there

android.os.NetworkOnMainThreadException. How to solve it?

做~自己de王妃 提交于 2019-12-02 13:22:47
I am trying to get my current location and get the driving directions to some destination. I am able to get my location and when I execute the code for the driving directions I get android.os.NetworkOnMainThreadException in the following line HttpResponse response = httpClient.execute(httpPost, localContext); Response is NULL. What do i do ? public Document getDocument(LatLng start, LatLng end, String mode) { String url = "http://maps.googleapis.com/maps/api/directions/xml?" + "origin=" + start.latitude + "," + start.longitude + "&destination=" + end.latitude + "," + end.longitude + "&sensor

Change minTime for GPS LocationListener dynamically

对着背影说爱祢 提交于 2019-12-02 12:31:34
The app that I'm writing uses the GPS location manager service requestLocationUpdates() but I would like to be able to change the min Time and min Distance parameters throughout the program. I initialize the location listener on creation but I can't figure out how to change these parameters or even find out if it's possible to do that. The main purpose for this would be to conserve battery life when the program doesn't need regular position updates. Thanks so much for your help! -Dom Judah Sali I'm not sure if this is correct, but faced with the same problem, I occasionally remove the