I would like to know if there is a way to identify that my App entered background from the ndk.
I have an application that spawns a pthread with
pthread_create(&_thread, NULL, methodToCall, NULL); //create a thread
Now this is all working perfectly fine. My problem is I only need the thread to run while the app is active. On iOS this is not a problem since the created thread is suspended by the system. On android however it continues to run even on the lock screen until you completely stop the app.
This is of course not so good for battery life. I know I could use a JNI Call from my Activities onStop() method. But this seems rather complicated.
So is there a better way for detecting within jni / c++ that my app has become inactive?