2016-08-25 5 views
0

こんにちは私はAndroid 6+の許可を処理するための簡単な許可ライブラリを使用しています。Android 6の許可Easy Permissionライブラリのハンドル「再確認しない」

は「再び尋ねることはありません」ときに呼び出す方法があります。これは、メソッドの定義

public static boolean checkDeniedPermissionsNeverAskAgain(final Object object, 
                   String rationale, 
                   @StringRes int positiveButton, 
                   @StringRes int negativeButton, 
                   @Nullable DialogInterface.OnClickListener negativeButtonOnClickListener, 
                   List<String> deniedPerms) { 
     boolean shouldShowRationale; 
     for (String perm : deniedPerms) { 
      shouldShowRationale = shouldShowRequestPermissionRationale(object, perm); 
      if (!shouldShowRationale) { 
       final Activity activity = getActivity(object); 
       if (null == activity) { 
        return true; 
       } 

       AlertDialog dialog = new AlertDialog.Builder(activity) 
         .setMessage(rationale) 
         .setPositiveButton(positiveButton, new DialogInterface.OnClickListener() { 
          @Override 
          public void onClick(DialogInterface dialog, int which) { 
           Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); 
           Uri uri = Uri.fromParts("package", activity.getPackageName(), null); 
           intent.setData(uri); 
           startAppSettingsScreen(object, intent); 
          } 
         }) 
         .setNegativeButton(negativeButton, negativeButtonOnClickListener) 
         .create(); 
       dialog.show(); 

       return true; 
      } 
     } 

     return false; 
    } 
である私たちは法

に渡すべきパラメータ知らない

EasyPermissions.checkDeniedPermissionsNeverAskAgain 

チェックです

しかし、我々はどのようにStringresを渡す。どんな助けでも大変感謝しています。ありがとう

+0

誰でも助けて理想的です –

答えて

1

あなたのstrings.xmlファイルのリソース値が必要です。したがって、R.string.okayR.string.cancelのようなものを渡してください。 strings.xmlファイルをセットアップしていない場合は(おそらく)、システムのデフォルトを使用して、そのメソッドにandroid.R.string.okandroid.R.string.cancelを渡すこともできます。そのようなシステム文字列がいくつか組み込まれています。好奇心が強い場合はhereをご覧ください。

+0

おかげさまで、ありがとうございましたパラメータをメソッドに渡すことができます –

関連する問題