0
携帯電話にAPKを新しくインストールしても、それを5回書き込んだ後にそれを書き込むと、Lat & Lngが出力されるようにしましたが、 t仕事...どのように私はそれを働かせますか?アンドロイドがTextviewに一貫してLat&Lngを出力できない
ログには、私がボタンを押していることが出力されますが、何もしないようです。私はテストしてるのデバイスは、 `とonLocationChanged()
方法でベロコード
getLocation = (LocationManager) getSystemService(LOCATION_SERVICE);
listenLocation = new LocationListener() {
@Override
public void onLocationChanged(Location location) {
townName.append(location.getLatitude() + " " + location.getLongitude());
}
@Override
public void onProviderDisabled(String provider) {
Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
startActivity(intent);
}
};
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
requestPermissions(new String[]{
android.Manifest.permission.ACCESS_FINE_LOCATION,android.Manifest.permission.ACCESS_COARSE_LOCATION,
android.Manifest.permission.INTERNET
}, 10);
return;
}
}else{
configureButton();
}
}
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults){
switch(requestCode){
case 10:
if (grantResults.length>0 && grantResults[0] == PackageManager.PERMISSION_GRANTED)
configureButton();
return;
}
}
private void configureButton() {
location.setOnClickListener(new View.OnClickListener(){
public void onClick(View view){
getLocation.requestLocationUpdates("gps", 5000, 0, listenLocation);
}
});
}
使用' FusedLocationProviderAPI'以下のAndroid 7
コードを実行している銀河S7エッジでありますGPSチェッカー ' – Piyush