MQTT和ActiveMQ
MQTT是一个轻量级的消息发布/订阅协议,它是实现基于手机客户端的消息推送服务器的理想解决方案。
消息订阅和推送
地址如下:
https://github.com/tokudu/AndroidPushNotificationsDemo
其服务类文件有许多方法过时例如:
The method onStart(Intent, int) from the type Service is deprecated
use onStartCommand instend of
The field ConnectivityManager.EXTRA_NETWORK_INFO is deprecated
解决方案:
建议使用getActiveNetworkInfo()
NetworkInfo
getActiveNetworkInfo() 获取当前连接可用的网络
http://blog.csdn.net/oyangyujun/article/details/41723865
http://blog.csdn.net/ygc87/article/details/7629749
The method setLatestEventInfo(Context, CharSequence, CharSequence, PendingIntent) from the type Notification is deprecated
解决方案
The Notification.Builder has been added to make it easier to construct Notifications.
在构造notification的时候有很多种写法,但是要注意,用
Notification notification = new Notification();
这种构建方法的时候,一定要加上notification.icon这个设置,不然,程序虽然不会报错,但是会没有效果。
Notification noti = new Notification.Builder(mContext)
.setContentTitle("New mail from " + sender.toString())
.setContentText(subject)
.setSmallIcon(R.drawable.new_mail)
.setLargeIcon(aBitmap)
.build();
2.信息推送方案
极光推送
https://www.jpush.cn/common/products
3.详细文档
http://blog.mcxiaoke.com/mqtt/protocol/MQTT-3.1.1-CN.pdf
- Android消息推送(二)--基于MQTT协议实现的推送功能
http://blog.csdn.net/johnny901114/article/details/8898727
ActiveMQ
一.Activemq 平台搭建与C#示列 http://www.cnblogs.com/woxpp/p/5001373.html
二.ActiveMQ 即时通讯服务 浅析 java示例 http://www.cnblogs.com/hoojo/p/active_mq_jms_apache_activeMQ.html
C#示例
下载
ActiveMQ官方网站下载最新版的Apache.NMS,网址:http://activemq.apache.org/nms/download.html,需要下载Apache.NMS和Apache.NMS.ActiveMQ两个bin包
http://www.apache.org/dyn/closer.lua/activemq/apache-nms/1.7.0/Apache.NMS.ActiveMQ-1.7.1-bin.zip
或者可以
http://www.apache.org/dyn/closer.lua/activemq/apache-nms
Mqtt各个平台下用到的包还有例子
https://github.com/mqtt/mqtt.github.io/wiki/libraries
Mqtt调试服务器
http://www.hivemq.com/blog/seven-best-mqtt-client-tools
MQTT.fx