I have an AlarmManager class, a simple class, an Application class and some other class.
The simple class is called by AlarmManager and then the simple class try to achieve the goal with the help of Application class. It shouldn’t matter whether or not my app is in the background; I need to ensure that these three classes are alive.
Now, my question is: Will the Android OS destroy these three classes (AlarmManager class, simple class, Application class), if my app is in background? If the answer is yes, then should I use Service? If I use Service, how should I implement it with these three classes?
edited:
i am trying to post status using facebook sdk in a particular time. So, the Alarm Manager class will call the simple class in a particular time. then the simple class will get some data (like session, message) from the Application class and then the simple class will post the message to user’s wall.
the session , message etc are stored in Application class from other activity class.
I might want to show some code for clarity. You probably don’t have an
AlarmManagerbut registered some of your components to be called by creating aPendingIntentand passing that to the system‘sAlarmManager. If that assumption is correct, if your app is not running (it doesn’t have a live process) at the time the alarm is triggered, Android will create one.And in the process load and instantiate all the classes that are used from your component. If your app is in the background (process is still there, ‘cached’), Android will reuse that process and call the necessary components.