1
次のコードでは、ifブロック内の行番号11のMY_PERMISSION_ACCESS_COURSE_LOCATIONを解決できません。可能性のあるものをすべてチェックし、依存関係でgoogle playサービスもコンパイルできますが、解決できません。 どうすればよいですか? 私は実際に5分ごとにユーザーの場所を追跡し、表示しています。 エラーはMY_PERMISSION_ACCESS_COURSE_LOCATIONを解決できません
Error:(60, 41) error: cannot find symbol variable MY_PERMISSION_ACCESS_COURSE_LOCATION
誰でもお手伝いできますか?
public Location getLocation() {
try {
if (ContextCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_COARSE_LOCATION)
!= PackageManager.PERMISSION_GRANTED)
{
ActivityCompat.requestPermissions(this, new String[]
{ android.Manifest.permission.ACCESS_COARSE_LOCATION
},
LocationServices.MY_PERMISSION_ACCESS_COURSE_LOCATION
);
Toast.makeText(GPSTracker.this, "open gps", Toast.LENGTH_SHORT).show();
}
Log.i("ok", "outside IF location");
locationManager = (LocationManager) mContext
.getSystemService(LOCATION_SERVICE);
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,
10000, // 3 sec
10, this);
// getting GPS status
isGPSEnabled = locationManager
.isProviderEnabled(LocationManager.GPS_PROVIDER);
// getting network status
isNetworkEnabled = locationManager
.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
if (!isGPSEnabled && !isNetworkEnabled) {
// no network provider is enabled
Toast.makeText(GPSTracker.this, "open it", Toast.LENGTH_SHORT).show();
}
this.canGetLocation = true;
if (isNetworkEnabled) {
locationManager.requestLocationUpdates(
LocationManager.NETWORK_PROVIDER,
MIN_TIME_BW_UPDATES,
MIN_DISTANCE_CHANGE_FOR_UPDATES, this);
if (locationManager != null) {
location = locationManager
.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
if (location != null) {
latitude = location.getLatitude();
longitude = location.getLongitude();
}
}
}
// if GPS Enabled get lat/long using GPS Services
if (isGPSEnabled) {
if (location == null) {
locationManager.requestLocationUpdates(
LocationManager.GPS_PROVIDER,
MIN_TIME_BW_UPDATES,
MIN_DISTANCE_CHANGE_FOR_UPDATES, this);
if (locationManager != null) {
location = locationManager
.getLastKnownLocation(LocationManager.GPS_PROVIDER);
if (location != null) {
latitude = location.getLatitude();
longitude = location.getLongitude();
}
}
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
return location;
}
のMY_PERMISSION_ACCESS_COARSE_LOCATIONを意味しなかった場合は、ここにあなたのコードを貼り付けてくださいチェックしています。 –
どのようなエラーが発生する可能性があります –
@ Michal_196 done – AndroidDEv