来自webservice的Android通知 [英] Android notification from webservice

查看:144
本文介绍了来自webservice的Android通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Android应用程序通过在Asp.Net上编写的WebServices与Microsoft SQLDatabase连接。现在我想要在Android应用程序上实时发送数据库发送通知的每一个变化吗?请给我写一些例子



我尝试过:



我想要从webservices发送通知到我的Android

解决方案

Web服务通过HTTP工作,因此不能推送通知。 HTTP仅在客户端发出Web服务器请求时才起作用。它始终是客户端请求,导致服务器响应。从来没有服务器任意联系客户端推送东西。



您的通知服务必须作为单独的服务运行,可能通过套接字(TCP / IP)运行。这意味着你的Android代码也必须有一个套接字服务器来接受来自通知服务的连接。



你可能遇到的问题是如果Android设备改变它的网络?例如,从WiFi到3G还是4G?它的IP地址会改变吗?这些信息如何回到服务器端服务,以便更新通知订阅?



有很多设计工作需要进入

I have Android application who is connecting with Microsoft SQLDatabase over WebServices who is write in Asp.Net. Now i want for every changes in database send notification on Android application in realtime? Please write me some Example

What I have tried:

I want send notification from webservices to my Android

解决方案

WebServices work over HTTP and therefor cannot PUSH a notification. HTTP works only when the client makes a request of the web server. It's ALWAYS a client request causing a response by the server. It is NEVER the server arbitrarily contacting a client to push something.

Your notification service has to run as a separate service, probably running over Sockets (TCP/IP). That means you're Android code also has to have a socket server in it to accept connections from the notification service.

A possible problem for you is what if the Android device changes the network it's on? For example, going from WiFi to 3G or 4G? Will its IP address change? How will this information get back to the server-side services so its subscription for notifications can be updated?

There'a lot of design work that has to go into this.


这篇关于来自webservice的Android通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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