Android App not asking for permissions when installing

前端 未结 3 925
孤街浪徒
孤街浪徒 2020-12-16 12:31

I work in the IT department of my university and we work on an app that installs the correct setup for the eduroam WiFi (maybe you have heard of it).

However I have

3条回答
  •  猫巷女王i
    2020-12-16 13:02

    if you want to request permissions at runtime you should write a special request in your app. Something like this:

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            createPermissions();
    }
    public void createPermissions(){
        String permission = Manifest.permission.READ_SMS;
        if (ContextCompat.checkSelfPermission(getContext(), permission) != PackageManager.PERMISSION_GRANTED){    
            if(!ActivityCompat.shouldShowRequestPermissionRationale(getActivity(), permission)){
                  requestPermissions(new String[]{permission}),
                            SMS_PERMISSION);
            }
        }
    }
    

提交回复
热议问题