diff --git a/.github/AAR Source (Android)/java/com/yasirkula/unity/RuntimePermissions.java b/.github/AAR Source (Android)/java/com/yasirkula/unity/RuntimePermissions.java index 18ea379..b87a986 100644 --- a/.github/AAR Source (Android)/java/com/yasirkula/unity/RuntimePermissions.java +++ b/.github/AAR Source (Android)/java/com/yasirkula/unity/RuntimePermissions.java @@ -109,7 +109,7 @@ public static void RequestPermission( final String[] permissions, final Context final Fragment request = new RuntimePermissionsFragment( permissionReceiver ); request.setArguments( bundle ); - ( (Activity) context ).getFragmentManager().beginTransaction().add( 0, request ).commit(); + ( (Activity) context ).getFragmentManager().beginTransaction().add( 0, request ).commitAllowingStateLoss(); } } } diff --git a/.github/AAR Source (Android)/java/com/yasirkula/unity/RuntimePermissionsFragment.java b/.github/AAR Source (Android)/java/com/yasirkula/unity/RuntimePermissionsFragment.java index 7648991..10a0129 100644 --- a/.github/AAR Source (Android)/java/com/yasirkula/unity/RuntimePermissionsFragment.java +++ b/.github/AAR Source (Android)/java/com/yasirkula/unity/RuntimePermissionsFragment.java @@ -9,7 +9,6 @@ import android.util.Log; import java.util.ArrayList; -import java.util.Random; /** * Created by yasirkula on 27.04.2018. @@ -40,7 +39,7 @@ public void onCreate( Bundle savedInstanceState ) { super.onCreate( savedInstanceState ); if( permissionReceiver == null ) - getFragmentManager().beginTransaction().remove( this ).commit(); + onRequestPermissionsResult( PERMISSIONS_REQUEST_CODE, new String[0], new int[0] ); else { m_permissions = getArguments().getStringArray( PERMISSIONS ); @@ -59,7 +58,7 @@ public void onRequestPermissionsResult( int requestCode, String[] permissions, i { Log.e( "Unity", "Fragment data got reset while asking permissions!" ); - getFragmentManager().beginTransaction().remove( this ).commit(); + getFragmentManager().beginTransaction().remove( this ).commitAllowingStateLoss(); return; } @@ -113,7 +112,7 @@ else if( !shouldShowRequestPermissionRationale( permission ) ) // This can cause result += permissionsResult.get( i ); permissionReceiver.OnPermissionResult( result ); - getFragmentManager().beginTransaction().remove( this ).commit(); + getFragmentManager().beginTransaction().remove( this ).commitAllowingStateLoss(); // Resolves a bug in Unity 2019 where the calling activity // doesn't resume automatically after the fragment finishes diff --git a/Plugins/AndroidRuntimePermissions/Android/RuntimePermissions.aar b/Plugins/AndroidRuntimePermissions/Android/RuntimePermissions.aar index 181bfa3..058b581 100644 Binary files a/Plugins/AndroidRuntimePermissions/Android/RuntimePermissions.aar and b/Plugins/AndroidRuntimePermissions/Android/RuntimePermissions.aar differ diff --git a/Plugins/AndroidRuntimePermissions/README.txt b/Plugins/AndroidRuntimePermissions/README.txt index c4393e8..b123848 100644 --- a/Plugins/AndroidRuntimePermissions/README.txt +++ b/Plugins/AndroidRuntimePermissions/README.txt @@ -1,27 +1,5 @@ -= Android Runtime Permissions (v1.2.0) = += Android Runtime Permissions (v1.2.1) = -Online documentation & example code available at: https://github.com/yasirkula/UnityAndroidRuntimePermissions -E-mail: yasirkula@gmail.com - -1. ABOUT -This plugin helps you query/request runtime permissions on Android M and later. - -2. HOW TO -You can use the following static functions of AndroidRuntimePermissions to manage runtime permissions: - -- bool CheckPermission( string permission ): checks whether or not the permission is granted - -- bool[] CheckPermissions( params string[] permissions ): queries multiple permissions simultaneously. The returned array will contain one entry per queried permission - -- Permission RequestPermission( string permission ): requests a permission from the user and returns the result. It is recommended to show a brief explanation before asking the permission so that user understands why the permission is needed and doesn't click Deny or worse, "Don't ask again". Permission is an enum that can take 3 values: --- Granted: permission is granted --- ShouldAsk: permission is denied but we can ask the user for permission once again. As long as the user doesn't select "Don't ask again" while denying the permission, ShouldAsk is returned --- Denied: we don't have permission and we can't ask the user for permission. In this case, user has to give the permission from app's Settings. This happens when user selects "Don't ask again" while denying the permission or when user is not allowed to give that permission (parental controls etc.) - -- Permission[] RequestPermissions( params string[] permissions ): requests multiple permissions simultaneously - -- Task RequestPermissionAsync( string permission ): asynchronous version of RequestPermission. Unlike RequestPermission, this function doesn't freeze the app unnecessarily before the permission dialog is displayed - -- Task RequestPermissionsAsync( string[] permissions ): asynchronous version of RequestPermissions - -- void OpenSettings(): opens the settings for this app, from where the user can manually grant permission(s) in case a needed permission's state is Permission.Denied \ No newline at end of file +Documentation: https://github.com/yasirkula/UnityAndroidRuntimePermissions +Example code: https://github.com/yasirkula/UnityAndroidRuntimePermissions#example-code +E-mail: yasirkula@gmail.com \ No newline at end of file diff --git a/package.json b/package.json index ea7e0cb..3b31c5b 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "com.yasirkula.androidruntimepermissions", "displayName": "Android Runtime Permissions", - "version": "1.2.0", + "version": "1.2.1", "documentationUrl": "https://github.com/yasirkula/UnityAndroidRuntimePermissions", "changelogUrl": "https://github.com/yasirkula/UnityAndroidRuntimePermissions/releases", "licensesUrl": "https://github.com/yasirkula/UnityAndroidRuntimePermissions/blob/master/LICENSE.txt",