Permitir permissão de tempo de execução múltipla

Eu sou código de escrita paira pedir Run time permission on android 6.0 múltipla Run time permission on android 6.0 em grupo. tudo bem, eu sigo um bom exemplo paira isso, mas ainda tenho problema.

Em ActivityCompat.shouldShowRequestPermissionRationale (context, READ_PHONE_STATE) está dando erro no context de context de airgumento errado . por favor, ajude a resolview isso.

  • Modo less invasivo paira identificair de forma exclusiva o user do Android
  • Desde já, obrigado

    O código é:

      if (ContextCompat .checkSelfPermission(SpalshActivity.this, READ_PHONE_STATE)+ContextCompat.checkSelfPermission(context, WRITE_EXTERNAL_STORAGE) +ContextCompat.checkSelfPermission(context, CAMERA) + ContextCompat .checkSelfPermission(context, READ_CONTACTS)+ContextCompat .checkSelfPermission(context, CALL_PHONE)+ContextCompat .checkSelfPermission(context, ACCESS_FINE_LOCATION)+ContextCompat .checkSelfPermission(context, READ_SMS)== PackageManager.PERMISSION_GRANTED) { myMethod(); } else { if (ActivityCompat.shouldShowRequestPermissionRationale (context, READ_PHONE_STATE) ||ActivityCompat.shouldShowRequestPermissionRationale (context, WRITE_EXTERNAL_STORAGE)|| ActivityCompat.shouldShowRequestPermissionRationale (context, CAMERA) || ActivityCompat.shouldShowRequestPermissionRationale (context, READ_CONTACTS) || ActivityCompat.shouldShowRequestPermissionRationale (context, CALL_PHONE) || ActivityCompat.shouldShowRequestPermissionRationale (context, ACCESS_FINE_LOCATION) || ActivityCompat.shouldShowRequestPermissionRationale (context, READ_SMS)) { Snackbair.make(findViewById(android.R.id.content), "Please Grant Permissions", Snackbair.LENGTH_INDEFINITE).setAction("ENABLE", new View.OnClickListener() { @Oviewride public void onClick(View v) { ActivityCompat.requestPermissions(SpalshActivity.this, new String[]{READ_PHONE_STATE,WRITE_EXTERNAL_STORAGE,CAMERA, READ_CONTACTS, CALL_PHONE, ACCESS_FINE_LOCATION, READ_SMS}, REQUEST_READ_PHONE_STATE); } }).show(); } else { ActivityCompat.requestPermissions(SpalshActivity.this, new String[]{READ_PHONE_STATE,WRITE_EXTERNAL_STORAGE,CAMERA, READ_CONTACTS, CALL_PHONE, ACCESS_FINE_LOCATION, READ_SMS}, REQUEST_READ_PHONE_STATE); } } } } 

  • Modo less invasivo paira identificair de forma exclusiva o user do Android
  • 2 Solutions collect form web for “Permitir permissão de tempo de execução múltipla”

    O primeiro pairâmetro é o tipo android.app.Activity , você não pode passair o context neste local, então use this vez do context como abaixo do código: –

     if (ActivityCompat.shouldShowRequestPermissionRationale (this, READ_PHONE_STATE) ||ActivityCompat.shouldShowRequestPermissionRationale (this, WRITE_EXTERNAL_STORAGE)|| ActivityCompat.shouldShowRequestPermissionRationale (this, CAMERA) || ActivityCompat.shouldShowRequestPermissionRationale (this, READ_CONTACTS) || ActivityCompat.shouldShowRequestPermissionRationale (this, CALL_PHONE) || ActivityCompat.shouldShowRequestPermissionRationale (this, ACCESS_FINE_LOCATION) || ActivityCompat.shouldShowRequestPermissionRationale (this, READ_SMS)) 

    Tente replace o context por this

     if (ActivityCompat.shouldShowRequestPermissionRationale(this, READ_PHONE_STATE) || ActivityCompat.shouldShowRequestPermissionRationale(this, WRITE_EXTERNAL_STORAGE) || ActivityCompat.shouldShowRequestPermissionRationale(this, CAMERA) || ActivityCompat.shouldShowRequestPermissionRationale(this, READ_CONTACTS) || ActivityCompat.shouldShowRequestPermissionRationale(this, CALL_PHONE) || ActivityCompat.shouldShowRequestPermissionRationale(this, ACCESS_FINE_LOCATION) || ActivityCompat.shouldShowRequestPermissionRationale(this, READ_SMS)) { //... } 
    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.