XaskeL

Untitled

Oct 17th, 2019
132
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class PermissionFragment extends Fragment {
  2. private static final int PERMISSIONS_REQUEST_CODE = 15887;
  3. public static final String PERMISSION_NAMES = "PermissionNames";
  4. private final IPermissionRequestResult m_ResultCallbacks;
  5.  
  6. public PermissionFragment() {
  7. this.m_ResultCallbacks = null;
  8. }
  9.  
  10. public PermissionFragment(IPermissionRequestResult iPermissionRequestResult) {
  11. this.m_ResultCallbacks = iPermissionRequestResult;
  12. }
  13.  
  14. public void onCreate(Bundle bundle) {
  15. super.onCreate(bundle);
  16. if (this.m_ResultCallbacks == null) {
  17. getFragmentManager().beginTransaction().remove(this).commit();
  18. } else {
  19. requestPermissions(getArguments().getStringArray(PERMISSION_NAMES), PERMISSIONS_REQUEST_CODE);
  20. }
  21. }
  22.  
  23. public void onRequestPermissionsResult(int i, String[] strArr, int[] iArr) {
  24. if (i == PERMISSIONS_REQUEST_CODE) {
  25. int i2 = 0;
  26. while (i2 < strArr.length && i2 < iArr.length) {
  27. if (iArr[i2] == 0) {
  28. this.m_ResultCallbacks.OnPermissionGranted(strArr[i2]);
  29. } else {
  30. this.m_ResultCallbacks.OnPermissionDenied(strArr[i2]);
  31. }
  32. i2++;
  33. }
  34. FragmentTransaction beginTransaction = getFragmentManager().beginTransaction();
  35. beginTransaction.remove(this);
  36. beginTransaction.commit();
  37. }
  38. }
  39. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×