Skip to content

feat: add is_initialized to check if the context has been set#4

Open
Frando wants to merge 1 commit intorust-mobile:masterfrom
Frando:feat/is-initialized
Open

feat: add is_initialized to check if the context has been set#4
Frando wants to merge 1 commit intorust-mobile:masterfrom
Frando:feat/is-initialized

Conversation

@Frando
Copy link
Copy Markdown

@Frando Frando commented Apr 29, 2026

This adds a fn is_initialized() -> bool to check whether a AndroidContext has been initialized. It is an addition only so fully backwards compatible and could be released as a patch release.

Motivation: I have library code that has an optional JNI path with a non-JNI fallback. Ideally, I want the library to be usable both by apps/crates that use ndk_context and by ones that don't for whatever reason. For the latter I want to use my non-JNI fallback path. However, currently it is not possible to branch on whether ndk_context has been initialized. The only function to get the context panics if it hasn't been initialized. With this addition, I can do the check and then branch between my JNI path (which requires ndk_context) and the non-JNI path.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant