I have to create an app in which I must set a date and at that specific date at 9 O'clock, I must give a notification. What is the simplest method of doing this? I want the app to work even when the app gets killed anyway. Is AlarmManager a solution?
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
To schedule an Action you can use the AlarmManager
Try this code it's work for me:
1 / Declare the BroadcastReceiver CLASS to launch the Action, this class can be inside your activity or outside in an other java file
2/ Inside your Oncreate Method put this code
Launch your App a Toast will be appeared after 3 seconds, So you can change "System.currentTimeMillis()+3000" with your wake up time.
You must use an
AlarmManager
to set an alarm ofRTC_WAKEUP
type.From the docs:
So this means that:
BroadcastListener
that listens to the BOOT_COMPLETE event to re-register the alarm after a device reboot.You should create the app as an android service.
Alarm manager is the solution i guess. you should set the alarm manager to a specific time and then make it call the notification in its onstart. and this should be implemented within a service. i hope it helped.