googlesamples / easypermissions

Simplify Android M system permissions
https://firebaseopensource.com/projects/googlesamples/easypermissions/
Apache License 2.0
9.86k stars 1.46k forks source link

OnActivityResult Deprecated in latest Android X AppCompatActivity #330

Open GulajavaMinistudio opened 3 years ago

GulajavaMinistudio commented 3 years ago

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

vishalkumarsinghvi commented 3 years ago

@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 :)

chitgoks commented 2 years ago

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

vishalkumarsinghvi commented 2 years ago

@chitgoks No response

JRobertson90 commented 2 years ago

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
});