I want to make my application set alarms every day at lets say 7 am a list of pills for the user. So far I have been doing it when a user adds a new pill, I will set the alarm directly, but I want to make it set alarms for today only. I am able to get a list of pills for some day using xpath, and getting the pills in a list. Now I was thinking if this is feasible to have some kind of hidden activity that keeps running or something that will set the daily pills. If someone could give me directions as to what I should be looking for to solve this problem, any kind of help would be appreciated.
Setting alarms daily android
188 Views Asked by hakuna matata At
2
There are 2 best solutions below
0
Naddy
On
I will give an idea for this.
Schedule the first
Alarmat 7 am using the set method ofAlarmManagerand register aBroadcastReceiverto be executed at 7 am using the sameAlarmManager.At 7 am your
AlarmandBroadcastReceiverwill execute. In theonReceivemethod of yourBroadcastReceiveragain set theAlarmandBroadcastReceiverso that it becomes a self loop.
pseudo code to set broadcastReceiver class:
Intent intent = new Intent(this, broadcastReceiver.class);
intent.putExtra("subject", subject);
PendingIntent pendingIntent = PendingIntent.getBroadcast(this,
0, intent, PendingIntent.FLAG_ONE_SHOT);
AlarmManager am= (AlarmManager) getSystemService(Context.ALARM_SERVICE);
am.set(AlarmManager.RTC_WAKEUP, "Your specific time", pendingIntent);
broadcastReceiver.class:
public class TimeAlarm extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
//set the alarm and broadcast receiver again
}
Related Questions in ANDROID
- Delay in loading Html Page(WebView) from assets folder in real android device
- MPAndroidChart method setWordWrapEnabled() not found
- Designing a 'new post' android activity
- Android :EditText inside ListView always update first item in the listview
- Android: Transferring Data via ContentIntent
- Wrong xml being inflated android
- AsyncTask Class
- Unable to receive extras in Android Intent
- Website zoomed out on Android default browser
- Square FloatingActionButton with Android Design Library
- Google Maps API Re-size
- Push toolbar content below statusbar
- Android FragmentPagerAdapter Circular listview
- Layout not shifting up when keyboard is open
- auDIO_OUTPUT_FLAG_FAST denied by client can't connect to localhost
Related Questions in ANDROID-ACTIVITY
- Android - No view found for fragment
- Does a recreated activity remember the original intent started it?
- I want to Show Simple Toast Message When User Click On Media Controller button Pause/Start/Stop in video View Using Media Controller
- Why does this run out of memory? Shouldn't the Activities be released?
- How to check in an (Android) async task if the activity it was called from was finished?
- Android Resources Not Found Exception
- How to handle multiple activity task in android when press home?
- Google Play services LocationSettingsAPI - LocationSettingsRequest Dialog not Showing
- How to land or navigate to previous activity if click on back button
- How to scale the imageview and view with matrix using seekBar?
- how to get the URL from mainActivity to the second activity using intents?
- Coordinator Layout with Toolbar in Fragments or Activity
- NullPointerException error in Android: Unable to instantiate
- ListView OnItemClickListener with a new Activity
- How can i send main activity to inner class inside of Fragment java class?
Related Questions in ALARMMANAGER
- Updating a widget every second with an AlarmManager and IntentService
- How to setup alarms again after reboot
- BroadCastReceiver and AlarmManager Usage
- Android repeating alarm not repeating correctly
- How to Create a Distinct PendingIntents
- set repeated reminder that repeats every month
- alarm manager sometimes firing at wrong times
- Android alarm not cancelling
- Is it possible to do a repeated task even if app is killed from Task Manager?
- Alarm Manager Not Firing
- Stop AlarmManager if the time has passed
- Android : AlarmManager is not working properly. It is not able to set the alarm
- Adding notification using alarm in android
- Alarm Manager doesn't work on time
- AlarmManager only works in near future
Related Questions in ANDROID-ALARMS
- Set repeating alarm multiple times a day and daily
- Alarm Manager Pending Intent not firing Service
- Alternative for alarm manager for periodic background tasks
- alarm manager/ service/ broadcast receiver is not working after app is closed or swiped away from the recent app
- startActivity for URI in Lockscreen on Android Nougat
- Android finish() method is not closing the app but minimizing it
- Which context does BroadcastReceivers receive when listening for BOOT_COMPLETED?
- Latest Android Alarm Clock Build
- AlarmManager: PendingIntent gone after swiping app from recent apps on some devices
- Android Alarm Scheduling with repeats
- RTC_WAKEUP doesn't work on all devices
- Android alarm is 12 hours late
- How to set Alarm for working days in android
- How can I keep track of when my repeating alarms goes off and update the set value?
- How can I set exact, repeating alarms in Android 4.4?
Related Questions in ALARMS
- Setting alarms daily android
- Cancelling a single alarm when you have multiple alarms
- Setting alarm clock to be shown in Clock application
- Graylog2 Alarms for non admins
- Android alarms, service as not been called
- Best approach to Triggering Event on SQL database
- AlarmManager.set(...) behavior not matching documentation. Am I doing something wrong?
- perl alarms not working as expected
- Multiple Alarms fired as one in an intent (List View)
- How to slave the Honeywell Tuxedo Touch to OpenHAB?
- Why alarms are not working when setting for next day and for long hours,when device is inactive for long duration the alarms are not fired
- How does one launch android version dependent alarm clock?
- Setting an alarm (as in alarm clock) using intents
- add multiple Alarms and alarm sound in Windows phone 8
- How to get notification when mobile in switch off mode
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
You should use: Alarm Manager. And place it in Service. Read also about BroadcastReceiver