targetSdkVersion如果是23以下,调用ActivityCompat.requestPermissions(),会弹出权限选择对话框,但是选择拒绝授权,onRequestPermissionsResult中的返回值却是PERMISSION_GRANTED,但选择同意授权,会把应用关闭重新开启当前activity,而不会调用onRequestPermissionsResult中的方法,所以不要在targetSdkVersion设置为23以下,又把complierSdkversion设置为23,这样会出现上述的问题。最好的方式是把targetSdkVersion也设置为23,就可以解决。一切完美运行。
下面是一些对应的解答:
The following are the Marshmallow permissions features every developer should keep in mind.
As you may already know, all permissions are divided into two categories: normal and dangerous. Android 5.1 and older versions display dangerous permissions during installation. If a user denies them an application will not be installed at all. Starting from Android 6.0 dangerous permissions are divided into subcategories (see below), that should be separately confirmed by a user while using an app. You should remember though that if one permis