I read the android developer guide. I got idea about android applcations a lot. But now I really want to develop one application. I have some basic questions in my mind. I would be glad to get their answers from experts.
-
In my application I need to check for the notification when the SIM card is removed from the phone and when put back. To check this which one will be the good idea? Is it a timer I should implement in my application or should I create a service which can respond to SIM card removal.
-
If I implement a timer to do a certain job at regular time interval, will the timer still can run if all the activities are in the background?
On all phones that I’ve seen in order to remove SIM the phone must be shut down, because battery usually blocks the SIM slot. So basically your app can not be notified about SIM removal because phone is off. What you can do is start your Service after phone restarts, via BroadcastReceiver listening for BOOT_COMPLETED: see this tutorial. Service then checks if SIM is available via
TelephonyManager.getSimState().Not necessarily. Android OS decides when to kill off and remove from memory the inactive apps. There is no guarantee that your inactive (e.g. in the background) app will not be removed. To guarantee scheduled execution look at
AlarmManager.