Repository navigation
Support an optional 'android_on_create' entrypoint - #239
Merged
Merged
Conversation
This adds support for an optional `android_on_crate` entrypoint which is called from within the Activity.onCreate native method callback from the Java main / UI thread. This gives applications an opportunity initialize state while the `Activity`'s class loader is on the stack, so `FindClass` will be able to find application classes. This can be a more-convenient place to initialize JNI bindings, without needing to explicitly get the class loader from the Activity to be able to look up application classes from the android_main thread. This may also be convenient for initially using JNI to interact with your new Activity in case you need to use SDK APIs that are only safe to use from the Java main / UI thread. The moves the thread initialization functions out of util.rs into a new init.rs While adding documentation for this feature, this also does a more-general pass over the top-level crate documentation to try and ensure it's up-to-date. Fixes: #169 Addresses: #82
rib
force-pushed
the
rib/pr/android-on-create-entrypoint
branch
from
March 19, 2026 16:19
b2ae99b to
854aac1
Compare
This was referenced Mar 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This adds support for an optional
android_on_crateentrypoint which is called from within theActivity.onCreatenative method callback from the Java main / UI thread.For example:
This gives applications an opportunity initialize state while the
Activity's class loader is on the stack, soFindClasswill be able to find application classes.This can be a more-convenient place to initialize JNI bindings, without needing to explicitly get the class loader from the Activity to be able to look up application classes from the android_main thread.
This may also be convenient for initially using JNI to interact with your new Activity in case you need to use SDK APIs that are only safe to use from the Java main / UI thread.
This moves the thread initialization functions out of util.rs into a new init.rs
While adding documentation for this feature, this also does a more-general pass over the top-level crate documentation to try and ensure it's up-to-date.
Fixes: #169
Addresses: #82