Setting up multiple alarms , restarting alarm app when phone restarts - android

I am trying to create an app where there would be multiple alarm(according to the will of user,so not definite ) but the i am unable to find any assistance. I also my app to run even if the phone is restarted. so in short i want to know about the operations of the usual alarm app that runs in the android phone

You can use a BroadcastReceiver to start your service when your phone restarts. In your service then you can register your alarms.
Here you can find an example:
Autostart Service on Device Boot

Related

how to trigger a react-native app to wake up? (for alarm)

Basically I am trying to add an alarm feature to my app.
set time & date, save >> turn the app off >> when it's the time, RING-RING-!
But to do this, the app should wake itself to run the alarm feature; otherwise it won't work unless the app is running at the alarm time.
Any regular alarm apps just open itself when its the time, even when the app was not running on the phone. does anyone here know how apps self-wake?
Thanks very much
Use AlarmManager to do alarm envenif the app is not running.
But if the machine reboot, it will not work. So we need to run a service to register alarm when machine boot complete.

Continuously running an app

I am making an Android app which is supposed to monitor the other running apps.
The question is, how do I make my app run continuously from when i first activate it. It should also start running by itself when I switch off and reboot the phone.
Any suggestions on how to ensure this? I am considering using a background thread but I am not convinced this alone will suffice.
You should make an android service that running continuusly in background
http://developer.android.com/guide/components/services.html
http://www.vogella.com/tutorials/AndroidServices/article.html
http://www.tutorialspoint.com/android/android_services.htm
Well you should try to have an Service into your app that could keep track of the other App's running
So Every Time the App start's the Service Would Start And Accordingly give The Updated to your app regarding the Other App Working
For Boot Time Start you Should Try System BroadCast Receiver
You should Really Follow this Tutorial
Create a service to monitor apps in the background.
http://developer.android.com/guide/components/services.html
To make the app load at boot:
Create a BroadcastReceiver and register it to receive ACTION_BOOT_COMPLETED. You also need RECEIVE_BOOT_COMPLETED permission.
Refer to this:
Android -Starting Service at Boot Time
You have to use a Service. But keep in mind that your service can be killed and restarted after a while.
And you should register a broadcast receiver to listen for ACTION_BOOT_COMPLETED so that you can start the service once the phone booted successfully.

Android service that was running when the phone was shut down starts automatically when the phone is booted

I am currently developing an Android telephony application that includes a service to handle all the SIP signaling for making and receiving calls.
I want this service to start exclusively when the user has correctly logged into the application. However, I am observing an undesired behavior: if the device is shut down while the app is running, the service is automatically started after the phone boots. This does not happen if the application is closed at the moment of shutting down the phone.
I have been reading about it but no answer comes up. Could anybody explain why this happens and how to prevent it?
Thank you in advance.
Thanks to CommonsWare comment I have quickly found the answer:
[...] The only way a service starts up is if somebody starts it, and the OS will not do that on its own.
I was so blinded thinking the OS was responsible for it that I didn't notice it was being done on purpose, as an undocumented feature inherited from a former version of the app.
There was a BroadcastReceiver listening to the android.intent.action.BOOT_COMPLETED action. This receiver was, among other things, restarting the service on start up when the app had not been properly shut down.
Thank you CommonsWare for your help.
Update
After preventing the BroadcastReceiver from listening to the BOOT_COMPLETE action, I still experience the same behavior.
The reason is that this BroadcastReceiver is also listening to connectivity changes to restart the SIP service when the WIFI or a data connection becomes active, only when the app is running. Wether the application was closed or not is stored in the app preferences, but this value was not properly set when the phone was shut down while the app was running.
That is why the service was still unwantedly starting on boot: because the BroadcastReceiver detected an android.net.conn.CONNECTIVITY_CHANGE at start up and the preference telling wether the app was still running or had been quit was not properly updated.

Can I keep my service on the device over power-off?

I hace attached my device to the PC and run my service via Eclipse on the device. Now I would like to see what is the behavior of my service over power-off and power-on. The problem is that once O power-off the device my service is lost. Is it possible to keep the application persistent on the device over power-off?
Thanks.
Your service will not run when the device is powered off - because well there is not power. But you can make the service available as soon as power is provided to the device. Make sure your service is efficient so it is not killed when memory is getting tight. Then just use a broadcast receiver to catch there
<action android:name="android.intent.action.BOOT_COMPLETED"/>
intent. From the receiver you can send and intent to launch your service. You could also use this intent in your service's Intent Filter to start the service. Use the PowerManager with a partial wake lock to help your service run when the screen is off - But note: This feature does not work on all devices - Of all the devices I have used this feature works on half, but not perfect.
If you want to help your service from not being killed by the OS even more - run it as a foreground service using the startForeground() API call in the service object.
instead start it again using broadcaste that is sent when device boots.. see here and here for more..

Reminder application

I am developing a reminder application. I am generating notifications using notification manager class, when the timeline crosses.But if my cell phone is switched off ,I am unable to see these notifications. Not even when i switch it on again.
Even if i switch it off and switch on again, i think the pending intents are destroyed and no notification is generated.
How do i get it when the phone is switched on again ?
Have a look at the AlarmManager:
From http://developer.android.com/reference/android/app/AlarmManager.html:
This class provides access to the system alarm services. These allow you to schedule your application to be run at some point in the future. When an alarm goes off, the Intent that had been registered for it is broadcast by the system, automatically starting the target application if it is not already running. Registered alarms are retained while the device is asleep (and can optionally wake the device up if they go off during that time), but will be cleared if it is turned off and rebooted.

Categories

Resources