0
내 앱에서 위치 서비스를 설정하려고합니다.몇 분 후에 GPS를 '포기'- 안드로이드
GPS 신호를 사용할 수없는 경우 (신호를 찾으려고 X 분 후에) 사용자에게 오류를 표시하고 싶습니다.
어떻게하면됩니까?
여기 내 코드는 지금까지의 -
// Acquire a reference to the system Location Manager
LocationManager locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
// Define a listener that responds to location updates
LocationListener locationListener = new LocationListener() {
public void onLocationChanged(Location location) {
// Called when a new location is found by the network location provider.
Log.d("loca", "accuracy - " + location.getAccuracy());
Log.d("loca", "longtitude - " + location.getLongitude());
Log.d("loca", "Latitude - " + location.getLatitude());
Log.d("loca", "Provider - " + location.getProvider());
if(isBetterLocation(location,bestLoc))
{
Log.d("loca", "best loc - yes");
bestLoc = location;
}
else
Log.d("loca", "best loc - no");
}
public void onStatusChanged(String provider, int status, Bundle extras) {}
public void onProviderEnabled(String provider) {}
public void onProviderDisabled(String provider) {}
};
// Register the listener with the Location Manager to receive location updates
if(locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER))
{
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,TWO_MINUTES , 300, locationListener);
Log.d("loca", "GPS");
}
else if(locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER))
{
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER,TWO_MINUTES , 300, locationListener);
Log.d("loca", "Net");
}
else
Log.d("loca", "Nothing");
어떻게 내가 신호를 찾고 시작했습니다 이후가되었습니다 얼마나 알 수 ?
감사합니다.