samsung S3で緯度と経度を取得していません.他のデバイスでは、コードは正常に機能し、適切な緯度と経度を取得しています.以下は、緯度と経度を取得するための私のコードです.
public class MainActivity extends Activity {
TextView textView1;
Location currentLocation;
double currentLatitude,currentLongitude;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
textView1 = (TextView) findViewById(R.id.textView1);
findLocation();
}
public void findLocation() {
LocationManager locationManager = (LocationManager) this
.getSystemService(Context.LOCATION_SERVICE);
LocationListener locationListener = new LocationListener() {
public void onLocationChanged(Location location) {
updateLocation(location,currentLatitude,currentLongitude);
Toast.makeText(
MainActivity.this,
String.valueOf(currentLatitude) + "\n"
+ String.valueOf(currentLongitude), 5000)
.show();
}
public void onStatusChanged(String provider, int status,
Bundle extras) {
}
public void onProviderEnabled(String provider) {
}
public void onProviderDisabled(String provider) {
}
};
locationManager.requestLocationUpdates(
LocationManager.NETWORK_PROVIDER, 0, 0, locationListener);
}
void updateLocation(Location location,double currentLatitude,double currentLongitude) {
currentLocation = location;
this.currentLatitude = currentLocation.getLatitude();
this.currentLongitude = currentLocation.getLongitude();
textView1.setText(String.valueOf(this.currentLatitude) + "\n"
+ String.valueOf(this.currentLongitude));
}
}
上記のコードでは、onLocationChanged() メソッドが S3 で実行されておらず、同じコードが Samsung S3 デバイスで動作していません。他のデバイスでは正常に動作しています。他のデバイスで正しい緯度と経度を取得しています。整理するのを手伝ってください。この問題..