I have a question while studying Android.
End Android
1.System.exit(1);
OR
2.android.os.Process.killProcess(android.os.Process.myPid());
I heard that if it ends like this, the process will be terminated.
If the process is terminated, will the sensor be automatically terminated?
Or, is it better to unregister the sensor just in case?
android application
Android systems attempt to maintain application processes internally for as long as possible. The reason why there are callback functions related to the life cycle in the components provided by Android also means that the Android system directly manages their life. Therefore, it is best practice for developers to delegate this to Android and write predictable code using the callback function rather than directly terminating the process. I think you'll have to rethink why you have to shut down the process yourself and whether this is the only solution.
Apart from that, registerListener/unregisterListener to receive sensor values always calling in pairs can prevent memory leaks and create flawless code.
© 2024 OneMinuteCode. All rights reserved.