实战 QQ demo源码(本例中有该应用)
服务器端下载:http://download.csdn.net/download/knight_black_bob/9822551
android eclipse 版:http://download.csdn.net/download/knight_black_bob/9822553
android stdio 版本:http://download.csdn.net/download/knight_black_bob/9822556
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"package="com.courriousby.baidupush"android:versionCode="1"android:versionName="1.0" ><uses-sdkandroid:minSdkVersion="9"android:targetSdkVersion="18" /><!-- Push service 运行需要的权限 --><uses-permission android:name="android.permission.INTERNET"/><uses-permission android:name="android.permission.READ_PHONE_STATE" /><uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /><uses-permission android:name="android.permission.WRITE_SETTINGS" /><uses-permission android:name="android.permission.VIBRATE" /><uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /><uses-permission android:name="android.permission.ACCESS_DOWNLOAD_MANAGER"/><uses-permission android:name="android.permission.DOWNLOAD_WITHOUT_NOTIFICATION" /><uses-permission android:name="android.permission.DISABLE_KEYGUARD" /><uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /><uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /><applicationandroid:allowBackup="true"android:icon="@drawable/ic_launcher"android:label="@string/app_name"android:theme="@style/AppTheme" ><activityandroid:name="com.courriousby.baidupush.MainActivity"android:label="@string/app_name" ><intent-filter><action android:name="android.intent.action.MAIN" /><category android:name="android.intent.category.LAUNCHER" /></intent-filter></activity><receiver android:name="com.courriousby.baidupush.BaiduPushReciever"><intent-filter><!-- 接收push消息 --><action android:name="com.baidu.android.pushservice.action.MESSAGE" /><!-- 接收bind,unbind,fetch,delete等反馈消息 --><action android:name="com.baidu.android.pushservice.action.RECEIVE" /><action android:name="com.baidu.android.pushservice.action.notification.CLICK" /></intent-filter></receiver><receiver android:name="com.baidu.android.pushservice.PushServiceReceiver"android:process=":bdservice_v1"><intent-filter><action android:name="android.intent.action.BOOT_COMPLETED" /><action android:name="android.net.conn.CONNECTIVITY_CHANGE" /><action android:name="com.baidu.android.pushservice.action.notification.SHOW" /><action android:name="com.baidu.android.pushservice.action.media.CLICK" /><action android:name="android.intent.action.MEDIA_MOUNTED" /><action android:name="android.intent.action.USER_PRESENT" /><action android:name="android.intent.action.ACTION_POWER_CONNECTED" /><action android:name="android.intent.action.ACTION_POWER_DISCONNECTED" /></intent-filter></receiver><receiver android:name="com.baidu.android.pushservice.RegistrationReceiver"android:process=":bdservice_v1"><intent-filter><action android:name="com.baidu.android.pushservice.action.METHOD" /><action android:name="com.baidu.android.pushservice.action.BIND_SYNC" /></intent-filter><intent-filter><action android:name="android.intent.action.PACKAGE_REMOVED"/><data android:scheme="package" /></intent-filter> </receiver><serviceandroid:name="com.baidu.android.pushservice.PushService"android:exported="true"android:process=":bdservice_v1" ><intent-filter><action android:name="com.baidu.android.pushservice.action.PUSH_SERVICE" /></intent-filter></service><service android:name="com.baidu.android.pushservice.CommandService"android:exported="true" /><activityandroid:launchMode="singleInstance"android:name="com.baidu.android.pushservice.PushKeepAlive"android:theme="@android:style/Theme.Translucent.NoTitleBar" /><meta-data android:name="api_key" android:value="GznlfC7K5jfSAHlZbtHfbfzz" /></application></manifest>
package com.courriousby.baidupush;import java.util.List;import android.content.Context;import com.baidu.android.pushservice.PushMessageReceiver;public class BaiduPushReciever extends PushMessageReceiver{@Overridepublic void onBind(Context context, int errorCode, String appid,String userId, String channelId, String requestId) {// TODO Auto-generated method stub}@Overridepublic void onDelTags(Context context, int errorCode,List<String> sucessTags, List<String> failTags, String requestId) {// TODO Auto-generated method stub}@Overridepublic void onListTags(Context context, int errorCode, List<String> tags,String requestId) {// TODO Auto-generated method stub}@Overridepublic void onMessage(Context context, String message,String customContentString){System.out.println(customContentString);}@Overridepublic void onNotificationClicked(Context context, String title,String description, String customContentString) {// TODO Auto-generated method stub}@Overridepublic void onNotificationArrived(Context context, String title,String description, String customContentString) {// TODO Auto-generated method stub}@Overridepublic void onSetTags(Context context, int errorCode,List<String> sucessTags, List<String> failTags, String requestId) {// TODO Auto-generated method stub}@Overridepublic void onUnbind(Context context, int errorCode, String requestId) {// TODO Auto-generated method stub}}
捐助开发者
在兴趣的驱动下,写一个免费
的东西,有欣喜,也还有汗水,希望你喜欢我的作品,同时也能支持一下。 当然,有钱捧个钱场(右上角的爱心标志,支持支付宝和PayPal捐助),没钱捧个人场,谢谢各位。
谢谢您的赞助,我会做的更好!