应用程式通知,后台服务的Andr​​oid引发 [英] In-app notification triggered from a background service android

查看:199
本文介绍了应用程式通知,后台服务的Andr​​oid引发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近,我正在开发应用程序的一些新功能。我的应用程序是关于显示了在特定时间和特定地点发生的不同事件。
现在,我希望用户能够保存一个事件像他最喜欢的,这意味着他可能要参加特定的事件。当用户标记的事件作为最喜欢的,事件和其他细节,如地点,名字的时候,描述将在设备上存储。现在,我有一些困难的部分是通知的部分。

我想要做的是,当时间的通知必须以告知该事件将在一小时内启动用户事件被触发开始前1小时。如果我会说,它与议程通知的比喻。

现在的问题是要实现它的正确方法。我知道如何使用通知的Andr​​oid 键,我也知道如何使用后台服务。我跟了很多像教程: http://www.tutorialspoint.com/android/android_services。 HTML ,但我不知道它是一个实现它的正确方法。

的一种方法是将数据存储在数据库中,并运行背景服务定期检查,如果手机的时间是触发通知用于event.But这会说,服务将无限期地运行该权利的背景。

我也想过使用数据库中的某些存储过程的检查是商店那边在时机成熟时,它会触发触发通知服务的价值。

我不知道如果我下面的正确方法,我需要澄清这些我再继续。

是否有任何教程,以帮助我或者任何其他的想法,可以帮助我实现了同样的事情。


解决方案

  

的一种方法是将数据存储在数据库中,并运行背景服务定期检查,如果手机的时间是触发通知用于event.But这会说,服务将无限期地运行该权利的背景。


这是相当浪费。难道就是编程相当于在车内高喊后座的孩子我们到了没?我们到了?


  

我也想过使用数据库中的某些存储过程的检查是商店那边在时机成熟时,它会触发触发通知服务的价值。


这是不是在Android的支持。


  

或任何其他的想法,帮助我实现同样的事情


使用 AlarmManager 告诉Android的给你的事件之前,控制一小时。在的PendingIntent 您使用 AlarmManager 使用可以触发广播接收器在你的应用程序,可以提高通知

Lately I am developing some new features of the app. My app is about displaying different events that are happening in a specific time and in a specific place. Now I want for the user to be able to save a event like his favorite, which means that he potentially wants to attend that particular event. When a user mark an event as a favorite one, the time of the event and other details like place, name, description will be store on the device. Now the part that I am having some difficulties is the notification part.

What I want to do is that when the time is 1 hour before the beginning of the event a notification must be triggered in order to tell the user that the event will start in an hour. If I will say its an analogy with the agenda notifications.

Now the problem is to the right way of implementing it. I know how to use Notification in Android and also I know how to use background services . I have followed a lot of tutorials like : http://www.tutorialspoint.com/android/android_services.html, but I don't know which is the right way of implementing it.

One way is to store the data in a database, and run a background service to check periodically if the time of the phone is the right to trigger a notification for an event.But this would say that the service would run indefinitely in the background.

I also thought about using some store procedures in the database that check the values that are store over there and when the time comes, it triggers the service that triggers the notification.

I don't know if I am following the right way and I need to clarify these before I proceed.

Is there any tutorial to help me or any other idea that helps me achieve the same thing.

解决方案

One way is to store the data in a database, and run a background service to check periodically if the time of the phone is the right to trigger a notification for an event.But this would say that the service would run indefinitely in the background.

This is rather wasteful. Is is the programming equivalent of the children in the back seat of the car chanting "are we there yet? are we there yet?".

I also thought about using some store procedures in the database that check the values that are store over there and when the time comes, it triggers the service that triggers the notification.

This is not supported in Android.

or any other idea that helps me achieve the same thing

Use AlarmManager to tell Android to give you control one hour before your event. The PendingIntent that you use with AlarmManager can trigger a BroadcastReceiver in your app that can raise the Notification.

这篇关于应用程式通知,后台服务的Andr​​oid引发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆