How to keep my application alive in background in processing android (APDE)

How to keep my application alive in background, even after closing the app and clearing off the ram…
I know this is possible without a ROOT, beacuse Reddit does it for notification purposes…
Thanks in advance…

How are you clearing?

Sorry I meant clearing cache

You will have to use Android’s lifecycle functions like onStop() to save the necessary data that can be used in onRestart().

But I want to make my sensors work in background…

You will need the AsyncTask class.(up till Android 10). At the moment I don’t have the time to make an programmatically example, but you could start trying to implement this, and this.