安卓6.0以上 就需要动态获取权限
static final String[] LOCATIONGPS = new String[]{Manifest.permission.ACCESS_COARSE_LOCATION,
Manifest.permission.ACCESS_FINE_LOCATION,
Manifest.permission.READ_PHONE_STATE};
/***
*
* @param activity
*/
public static void openQuanXian(final Activity activity){
if (Build.VERSION.SDK_INT >= 23) {
//--------------设置白名单
Intent ignore = new Intent();
ignore.setData(Uri.parse("package:"+activity.getPackageName()));
ignore.setAction(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS);
activity.startActivity(ignore);
//判断是否为android6.0系统版本,如果是,需要动态添加权限
if (ContextCompat.checkSelfPermission(activity, Manifest.permission.ACCESS_FINE_LOCATION)
!= PERMISSION_GRANTED) {// 没有权限,申请权限。
ActivityCompat.requestPe