My app has a special ON and OFF feature. So when the app is in ON mode, the notification is always present via flags
notification.flags |= Notification.FLAG_NO_CLEAR;
notification.flags |= Notification.FLAG_ONGOING_EVENT;
When the app is in OFF mode, the notification is gone. The ON and OFF modes has nothing with app running or not!!!
So, when a user closes app (onStop is being called) and reopens the app, I need app to detect if it is in ON or OFF mode. That is why I would need an app to detect if this notification exists or not.
How can I detect it?
You should store this on/off state somewhere else, such as SharedPreferences. Then post/cancel the notification to match the on/off state.