在我的应用程序中,我需要当前位置才能在ATM附近找到。我使用gms来查找具有运行时权限的当前位置,它适用于6.0-6.0.1和5.0。问题是在7.0关闭三星和5.1版本的应用程序。我将ACCESS_FINE_LOCATION
和ACCESS_COURSE_LOCATION
权限放在android清单中。我使用目标sdk版本25。
@Override
public void onLocationReceived(Location location) {
if (location != null) {
latLng = new LatLng(location.getLatitude(), location.getLongitude());
address=new FetchAddress(RegisterActivity.this,latLng);
Log.e("My Address",address.getAddress());
Log.e("My Locality",address.getLocality());
tracker1.stopLocationUpdates();
}
}
答案 0 :(得分:0)
嘿,你的问题清楚地表明你没有写下你的部分许可。
您可能会获得像
这样的棉花糖的许可if(android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M){
//after success you call some method
getLocation();
}
此功能仅在marshmallow
您必须如下所示编写其他部分许可
if(android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M){
//after success you call some method
getLocation();
dependentData(); //Main function
}else
{
dependentData(); // If Is > 6 or < 5.0 no matter this should be executed
}
试试这个希望它的作品。