You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is it possible to override methods on the android activity?
For example I'm working on https://github.com/matthunz/permissions and I want to find a way to override onRequestPermissions for the activity. If this isn't possible yet I'm thinking a trait with these methods on it would be a cool idea
The text was updated successfully, but these errors were encountered:
It's not possible to subclass and override class methods from a Rust crate / JNI unfortunately, no.
The developer for the application can subclass the Activity (Either subclass NativeActivity or GameActivity) and then hook into onRequestPermissions there, and potentially call some API that your crate would document as a requirement.
Glad to see someone looking at permissions here though - I was recently starting to poke at this for Android too but haven't found much time to look at it yet still.
That API doesn't actually require you to override onRequestPermissions, but it does require the app to be based on AppCompatActivity (Which is the case with GameActivity)
Alternatively you can subclass android.app.Fragment and implement onRequestPermissionsResult for the Fragment subclass and use Fragment::requestPermissions. This would enable the crate to work without needing to modify the Activity I believe but it will require a small amount of support code written in Java/Kotlin.
When I started looking at this recently I was initially looking at that last approach.
Is it possible to override methods on the android activity?
For example I'm working on https://github.com/matthunz/permissions and I want to find a way to override
onRequestPermissions
for the activity. If this isn't possible yet I'm thinking a trait with these methods on it would be a cool ideaThe text was updated successfully, but these errors were encountered: