简体   繁体   English

应用关闭时的通知

[英]Notifications when the app is turned off

I wonder if it is possible to have notifications show up even if the app is turned off. 我想知道即使关闭了应用程序,是否也可能显示通知。

say for example I have an app and I set some kind of notification for 13.00 the next day and then turn the app off or restart my phone or something. 例如说我有一个应用程序,第二天我为13.00设置了某种通知,然后关闭该应用程序或重新启动我的手机或其他东西。

Is it possible to still get a notification in the notification bar with some text that starts the app or do the app need to run in the background to be able to use notifications? 是否仍可能在通知栏中收到带有一些可启动应用程序的文本的通知,或者该应用程序需要在后台运行才能使用通知?

if it is possible, what is the best way to do this? 如果可能的话,最好的方法是什么? (get a notification at a certain time that starts the app) and if not, how do you recommend doing notifications? (在启动应用程序的特定时间获得通知),如果没有,您如何建议进行通知?

The type of notifcations I want to do are reminder notifications. 我想做的通知类型是提醒通知。

thanks for all help! 谢谢大家的帮助!

AlarmManager和Service的组合将帮助您执行您正在寻找的任务,我已经执行了此操作。请查看android教程。

What you're looking for is a background service. 您正在寻找的是后台服务。 See this Android Services tutorial . 请参阅此Android服务教程

In the background service, your app should check periodically and when necessary, create and issue new notifications. 在后台服务中,您的应用应定期检查,并在必要时创建并发布新通知。 See this Android Notifications tutorial . 请参阅此Android Notifications教程

The background service can be set to automatically start when the phone is restarted, and to re-issue any uncleared notification again. 可以将后台服务设置为在重新启动电话时自动启动,并重新发出任何未清除的通知。

Many apps such as Gmail already do this. Gmail等许多应用程序已经可以执行此操作。 Although you must be careful in resource usage or Android might kill your service. 尽管您必须谨慎使用资源,否则Android可能会终止您的服务。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Android 关闭飞行模式时应用程序崩溃 - Android App crushes when airplane mode is turned off 当我的应用程序启动前台服务时,如果用户在设置中关闭了通知权限,那么服务是否在前台? - When my app starts a foreground service, is the service in foreground if user has turned off notification permission in settings? 当应用程序停止/设备关闭时,在 android 上保存片段状态/数据 - save fragment state/data on android when app stopped/device turned off 关闭飞行模式时,为什么 Android 应用程序 go 通过活动和片段生命周期方法 - Why does an Android app go through the activity and fragment lifecycle methods when airplane mode is turned off 套接字仅在防火墙关闭时有效 - Socket only works when firewall turned off 屏幕关闭时,OnPause返回NullPointerException - OnPause return NullPointerException when screen is turned off JavaFX-屏幕关闭时的绘图组件 - JavaFX - Drawing component when the screen is turned off 即使在Android中关闭了屏幕,如何保持应用状态? - How to keep app status even if screen is turned off in Android? 按下按钮时Flash未关闭(手电筒应用程序) - Flash not being turned off on button press(Flashlight App) 当屏幕关闭时,Bluetoothlescanner 停止扫描或扫描频率降低 - Bluetoothlescanner stop scanning or scan less often when screen is turned off
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM