Skip to content

Commit

Permalink
Potential fix for IllegalStateException on Android
Browse files Browse the repository at this point in the history
  • Loading branch information
yasirkula committed Nov 14, 2023
1 parent 095ca3f commit b6e0fd9
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ public static void PickMedia( Context context, final NativeGalleryMediaReceiver
final Fragment request = new NativeGalleryMediaPickerFragment( mediaReceiver );
request.setArguments( bundle );

( (Activity) context ).getFragmentManager().beginTransaction().add( 0, request ).commit();
( (Activity) context ).getFragmentManager().beginTransaction().add( 0, request ).commitAllowingStateLoss();
}

@TargetApi( Build.VERSION_CODES.M )
Expand Down Expand Up @@ -384,7 +384,7 @@ public static void RequestPermission( Context context, final NativeGalleryPermis
final Fragment request = new NativeGalleryPermissionFragment( permissionReceiver );
request.setArguments( bundle );

( (Activity) context ).getFragmentManager().beginTransaction().add( 0, request ).commit();
( (Activity) context ).getFragmentManager().beginTransaction().add( 0, request ).commitAllowingStateLoss();
}

// Credit: https://stackoverflow.com/a/35456817/2373034
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@ else if( resultCode != Activity.RESULT_OK || data == null )
}

if( resultFragment == null )
getFragmentManager().beginTransaction().remove( this ).commit();
getFragmentManager().beginTransaction().remove( this ).commitAllowingStateLoss();
else
getFragmentManager().beginTransaction().remove( this ).add( 0, resultFragment ).commit();
getFragmentManager().beginTransaction().remove( this ).add( 0, resultFragment ).commitAllowingStateLoss();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,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;
}

Expand Down Expand Up @@ -107,7 +107,7 @@ public void onRequestPermissionsResult( int requestCode, String[] permissions, 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
Expand Down
Binary file modified Plugins/NativeGallery/Android/NativeGallery.aar
Binary file not shown.
2 changes: 1 addition & 1 deletion Plugins/NativeGallery/README.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
= Native Gallery for Android & iOS (v1.7.6) =
= Native Gallery for Android & iOS (v1.7.7) =

Documentation: https://github.com/yasirkula/UnityNativeGallery
FAQ: https://github.com/yasirkula/UnityNativeGallery#faq
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "com.yasirkula.nativegallery",
"displayName": "Native Gallery",
"version": "1.7.6",
"version": "1.7.7",
"documentationUrl": "https://github.com/yasirkula/UnityNativeGallery",
"changelogUrl": "https://github.com/yasirkula/UnityNativeGallery/releases",
"licensesUrl": "https://github.com/yasirkula/UnityNativeGallery/blob/master/LICENSE.txt",
Expand Down

0 comments on commit b6e0fd9

Please sign in to comment.