saleemrashid / android_log-rs

:ledger: Logger which writes to Android logging subsystem
Apache License 2.0
4 stars 3 forks source link

A function to detect whether `init` had been called previously, please #2

Open martinellison opened 4 years ago

martinellison commented 4 years ago

It would be nice to have a way of finding out whether the log had been initialised already (i.e. whether init had been called already). This is because Android apps are often restarted automatically (e.g. when the phone is rotated 90 degrees), which causes a call to Activity.onCreate() in the activity, which may result in a call to android_log::init() in Rust, which is an error after the first time.

rushiiMachine commented 4 days ago

Just put the call to android_log::init() inside your JNI_OnLoad, then it's guarenteed to only ever be called once