easypermissions icon indicating copy to clipboard operation
easypermissions copied to clipboard

OnActivityResult Deprecated in latest Android X AppCompatActivity

Open GulajavaMinistudio opened this issue 3 years ago • 4 comments

Basic Information

Device type: Android with version 10 and 11 OS version: Android 10 and Android 11 EasyPermissions version: 3.0.0

Describe the problem

AppSettings dialog need onActivityResult for Appsettings dialog callback. And for this case, onActivityResult is deprecated on latest Android X Appcompat activity version.

https://stackoverflow.com/questions/62671106/onactivityresult-method-is-deprecated-what-is-the-alternative

https://developer.android.com/training/basics/intents/result

JbJvj

GulajavaMinistudio avatar Jun 08 '21 04:06 GulajavaMinistudio

@GulajavaMinistudio onRequestPermissionsResult also deprecated and I am also waiting for new version , if you found something please write down below so it will be helpful for me Thanks :)

vishalkumarsinghvi avatar Jun 30 '21 07:06 vishalkumarsinghvi

@vishalkumarsinghvi did they confirm they will update the lib that will handle that deprecation?

chitgoks avatar Oct 17 '21 02:10 chitgoks

@chitgoks No response

vishalkumarsinghvi avatar Oct 17 '21 04:10 vishalkumarsinghvi

I also wish they would update the library but you can still use an activity launcher without even modifying the library:

AppSettingsDialog dialog = new AppSettingsDialog.Builder(this).build();
@SuppressLint("RestrictedApi") Intent intent = AppSettingsDialogHolderActivity.createShowDialogIntent(this, dialog);
appSettingsDialogLauncher.launch(intent);

and your launcher in your activity or fragment would look like this:

private final ActivityResultLauncher<Intent> appSettingsDialogLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> {
    // handle result here
});

JRobertson90 avatar May 06 '22 04:05 JRobertson90