Android GPS Location Request Failed for Some Phones -


I am currently developing an Android app using android.location.API.

Usually the GPS location request succeeded in some phones (Galaxy Note 2), but failed (getLastKnownLocation () empty returns) in others (Galaxy S3 and S4).

It was weird that GPS worked for S & E; S4 If I had previously activated the function "GPS Satellite View" built in Samsung which will make the satellites available.

My guess is that both S3 & amp; S4s are using Mediatek chips that provide poor GPS signals. Does anyone know how to do functions like scan satellites in Android?

Note that my app is used in China, please do not suggest any services related to Google.

Thank you.

Public Class MyLocationManager Android. Location.LocationListener {Private Static MyLocationManager Example = Zero; Private Location Current Location; Private string provider; Personal Location Manager Location Manager; Personal reference references; Public stable MyLocationManager getInstance () {if (example == zero) {instance = new MyLocationManager (); } Return Example; } There is a place in the public boolean () {if (currentLocation == null) {return false; } And {return true; }} Public float distance mmframe space (double latitude, double longitude) {if (currentLocation == null) {return -1; } Float [] result = new float [3]; Location control (current location.Getlightitude), current location Quantitative (), latitude, longitude, result); Return Results [0]; } Public Zero Start Station (reference reference) {this.context = context; LocationManager = (LocationManager) context.getSystemService (context.LOCATION_SERVICE); Boolean GPS Attached = locationManager.isProviderEnabled (LocationManager.GPS_PROVIDER); Boolean wifiEnabled = locationManager.isProviderEnabled (LocationManager.NETWORK_PROVIDER); If (GPS-related) {provider = LocationManager.GPS_PROVIDER; Logs. E ("MyLocationManager", "GPS"); } And if (wifiEnabled) {provider = LocationManager.NETWORK_PROVIDER; Logs. E ("MyLocationManager", "NetWork"); } Else {Log.e ("MyLocationManager", "Please enable location service"); Return; } RequestLocationUpdates (); If (provider.equals (LocationManager.GPS_PROVIDER)) {currentLocation = locationManager.getLastKnownLocation (provider); } And {currentLocation = locationManager.getLastKnown location (provider); } If (current location == blank & provider. Same (LocationManager.GPS_PROVIDER)) {Log.e ("MyLocationManager", "GPS Fail"); If (wifiEnabled) {Log.e ("MyLocationManager", "Use Wifi"); Provider = Location Manager. NETWORK_PROVIDER; RequestLocationUpdates (); CurrentLocation = locationManager.getLastKnownLocation (provider); } And {return; }}} Public void stopListenLocation () {// Stop updating after recovering the location location. Manager .removeUpdates (this); } Public Zero Request Location Update () (if (Provider! = Null & amp; Provider.) Empty ()) {locationManager.requestLocationUpdates (Provider, 60000, 10, this); } Else {Log.e ("MyLocationManager", "Request location update unsuccessful: provider is empty."); }} @ Override public wide online change (location location) {currentLocation = location; Log D. ("Sonic", "changing location" + location); } @ Override Status Changed (string s, int i, bundle bundle) {} @ override public recourse on propriet enabled (string s) {} @ override public records on proprietor (string s) {}}

Actually this is a device problem.

Some devices getLastKnownLocation (like Motorola XT720) you must implement the LocationListener and dump yourself into onLocationChanged You must save location updates in shared contexts . And when getLastKnownLocation is a zero place which is a saved place.

You can go as far as possible with the best provider approach to get as much space as possible.

Read the blog Hope it helps you.


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -