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