-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
641ee7d
commit 3c4b8a2
Showing
3 changed files
with
44 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
app/src/main/java/com/aquaapps/readtorecite/PermissionController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.aquaapps.readtorecite; | ||
|
||
import android.content.pm.PackageManager; | ||
|
||
import androidx.annotation.CheckResult; | ||
import androidx.annotation.NonNull; | ||
import androidx.annotation.RequiresPermission; | ||
import androidx.appcompat.app.AppCompatActivity; | ||
import androidx.core.app.ActivityCompat; | ||
import androidx.core.content.PermissionChecker; | ||
|
||
public class PermissionController { | ||
public static void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults){ | ||
// TODO: | ||
} | ||
public static void requestPermissions(AppCompatActivity activity,@NonNull String[] permissions){ | ||
for (String permission: | ||
permissions) { | ||
requestPermission(activity,permission); | ||
} | ||
} | ||
public static void requestPermission(AppCompatActivity activity,String permission){ | ||
if(ActivityCompat.checkSelfPermission(activity,permission)== PackageManager.PERMISSION_DENIED && | ||
ActivityCompat.shouldShowRequestPermissionRationale(activity,permission)){ | ||
ActivityCompat.requestPermissions(activity,new String[]{permission},114514); | ||
} | ||
} | ||
} |