简体   繁体   English

将新数据发布到远程服务器时,如何警告Android应用程序的用户?

[英]How do I alert users of an Android app when new data is posted to a remote server?

I am developing an Android application for an already existing website. 我正在为一个已经存在的网站开发一个Android应用程序。 When ever a user enters some data into the website (like a forum post), all the other users should be alerted about that post. 每当用户在网站中输入一些数据(例如论坛帖子)时,所有其他用户都应收到有关该帖子的警报。 Is it possible? 可能吗?

I think this is possible with triggers. 我认为使用触发器可以做到这一点。 Am I correct? 我对么?

You can try 'Android Cloud to Device Messaging Framework' which can push messages to your android application. 您可以尝试使用“ Android云到设备消息传递框架”,该框架可以将消息推送到您的android应用程序。

http://code.google.com/android/c2dm/ http://code.google.com/android/c2dm/

What you search for is called "Server pushing". 您搜索的内容称为“服务器推送”。 Your "listeners/observers", these are the mobile phones, register to a subject (in this case the server) at initialization. 您的“听众/观察者”是移动电话,在初始化时注册到主题(在这种情况下为服务器)。 Then they are listening for new calls all the time (Thread). 然后他们一直在监听新的呼叫(线程)。 If the data on server will be refreshed, every observer gets a call. 如果将刷新服务器上的数据,则每个观察者都会接到一个电话。 If your server is running on Java, you could use "observer pattern" for this. 如果您的服务器在Java上运行,则可以为此使用“观察者模式”。 Maybe you could use UDP calls to notify your observers. 也许您可以使用UDP调用来通知您的观察者。 After your observers receive the call, they "refresh" their data via an usual HTTP call. 观察者收到呼叫后,他们将通过常规HTTP呼叫“刷新”其数据。 If you are running php with a database you could save the IPs of your observers into the database (when they register on the server) iterate over it, and send them an UDP call, after a form submit is executed. 如果您使用数据库运行php,则可以在执行表单提交后将观察者的IP保存到数据库中(当他们在服务器上注册时),并对其进行迭代,并向他们发送UDP调用。

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

相关问题 当服务器上有新数据可用时,如何将通知推送到android app? - How to push notification to android app, when new data is available at server? 在Android中发布消息时如何向用户发送通知 - How to send notifications to users when a message is posted in Android 如何在Android应用程序的警报对话框中为用户输入编码? - How do I code for user input in an alert dialog for an android app? 没有数据从Android发布到服务器 - No data posted to server from android 如何使用JSON从远程数据库检索数据并显示在android应用程序xml文件中? - How do i retrieve the data using JSON from the Remote Database and display in my android app xml file? 当用户在Android中登录应用程序时,如何保存数据? - How do i save data when user is logged in the app in Android? 当用户登录Firebase Android应用程序时,如何向用户显示其他登录用户的列表? - How do I show list of other logged in users to a user when he/she logs in to the app in firebase, Android? 如何知道 POST 数据是否是从 Android 应用程序中发布的? - How to know if POST data is posted from within an Android App? Android 显示服务器上发布的新消息的应用程序 - Android Application that displays new messages posted on a server 将数据从android应用保存到远程服务器 - Saving data from android app to remote server
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM