转载的,感谢作者,由于我找了很久才找到这个解决方法,因此我自己再转一遍
原文链接
https://blog.csdn.net/qinwendou/article/details/77849048
if (ContextCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED
|| ContextCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED)
{}
---------------------