Skip to content
This repository was archived by the owner on Oct 3, 2024. It is now read-only.
This repository was archived by the owner on Oct 3, 2024. It is now read-only.

@AfterPermissionGranted should also be annotated with @Keep #137

@loki666

Description

@loki666

if using proguard optimization, a @AfterPermissionGranted method could be completly inlined preventing EasyPermissions.onRequestPermissionsResult to find it.

private static final int REQUEST_PERMISSION = 10;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    navigateToPlayer();
}

@Keep
@AfterPermissionGranted(REQUEST_PERMISSION)
private void navigateToPlayer() {
    if (EasyPermissions.hasPermissions(this, Manifest.permission.READ_EXTERNAL_STORAGE)) {
        Intent intent = new Intent(this, MusicPlayerActivity.class);
        startActivity(intent);
        finish();
    } else {
        EasyPermissions.requestPermissions(this, getString(R.string.read_permission_rational), REQUEST_PERMISSION, Manifest.permission.READ_EXTERNAL_STORAGE);
    }
}

@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
    super.onRequestPermissionsResult(requestCode, permissions, grantResults);

    // Forward results to EasyPermissions
    EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this);
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions