Android_开源框架_JPush极光推送
来源:互联网 发布:镇魔曲手游数据库 编辑:程序博客网 时间:2024/05/17 01:35
本博文为子墨原创,转载请注明出处!
http://blog.csdn.net/zimo2013/article/details/17282081
1.JPush极光推送下载
JPush下载,具体Document点此查看
2.AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.push" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="18" /> <permission android:name="com.example.push.permission.JPUSH_MESSAGE" android:protectionLevel="signature" /> <uses-permission android:name="com.example.push.permission.JPUSH_MESSAGE" /> <uses-permission android:name="android.permission.RECEIVE_USER_PRESENT" /> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.WAKE_LOCK" /> <uses-permission android:name="android.permission.READ_PHONE_STATE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.VIBRATE" /> <uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name="com.example.push.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> <service android:name="cn.jpush.android.service.PushService" android:enabled="true" android:exported="false" > <intent-filter> <action android:name="cn.jpush.android.intent.REGISTER" /> <action android:name="cn.jpush.android.intent.REPORT" /> <action android:name="cn.jpush.android.intent.PushService" /> <action android:name="cn.jpush.android.intent.PUSH_TIME" /> </intent-filter> </service> <!-- Required SDK核心功能--> <activity android:name="cn.jpush.android.ui.PushActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar" android:configChanges="orientation|keyboardHidden" > <intent-filter> <action android:name="cn.jpush.android.ui.PushActivity" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="com.example.push" /> </intent-filter> </activity> <service android:name="cn.jpush.android.service.DownloadService" android:enabled="true" android:exported="false" > </service> <receiver android:name="cn.jpush.android.service.PushReceiver" android:enabled="true" > <intent-filter android:priority="1000" > <!-- since 1.3.5 --> <action android:name="cn.jpush.android.intent.NOTIFICATION_RECEIVED_PROXY" /> <!-- since 1.3.5 --> <category android:name="com.example.push" /> <!-- since 1.3.5 --> </intent-filter> <!-- since 1.3.5 --> <intent-filter> <action android:name="android.intent.action.USER_PRESENT" /> <action android:name="android.net.conn.CONNECTIVITY_CHANGE" /> </intent-filter> <intent-filter> <action android:name="android.intent.action.PACKAGE_ADDED" /> <action android:name="android.intent.action.PACKAGE_REMOVED" /> <data android:scheme="package" /> </intent-filter> </receiver> <!-- Required SDK核心功能 --> <receiver android:name="cn.jpush.android.service.AlarmReceiver" /> <!-- User defined. For test only 用户自定义的广播接收器 --> <receiver android:name=".MyReceiver" android:enabled="true" > <intent-filter> <action android:name="cn.jpush.android.intent.REGISTRATION" /> <!-- Required 用户注册SDK的intent --> <action android:name="cn.jpush.android.intent.UNREGISTRATION" /> <action android:name="cn.jpush.android.intent.MESSAGE_RECEIVED" /> <!-- Required 用户接收SDK消息的intent --> <action android:name="cn.jpush.android.intent.NOTIFICATION_RECEIVED" /> <!-- Required 用户接收SDK通知栏信息的intent --> <action android:name="cn.jpush.android.intent.NOTIFICATION_OPENED" /> <!-- Required 用户打开自定义通知栏的intent --> <action android:name="cn.jpush.android.intent.ACTION_RICHPUSH_CALLBACK" /> <!-- Optional 用户接受Rich Push Javascript 回调函数的intent --> <category android:name="com.example.push" /> </intent-filter> </receiver> <!-- Required . Enable it you can get statistics data with channel --> <meta-data android:name="JPUSH_CHANNEL" android:value="developer-default" /> <meta-data android:name="JPUSH_APPKEY" android:value="----AppKey----" /> <!-- </>值来自开发者平台取得的AppKey --> </application></manifest>
3.Activity
public class MainActivity extends Activity {@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main); JPushInterface.setDebugMode(true); //设置开启日志,发布时请关闭日志 JPushInterface.init(this); // 初始化 JPush}}
4.发送通知
String app_key = "app_key";//TODOString master_secret = "master_secret";//TODOString sendno = "1";String receiver_type = "4";String str = sendno+receiver_type+master_secret;String md5 = MD5Encoder.encode(str);String json = "{\"n_content\":\"需要发送的消息\"}";//POST提交,发送json内容byte[] bytes = NetUtil.post("http://api.jpush.cn:8800/v2/push","sendno="+sendno+"&app_key="+app_key+"&receiver_type="+receiver_type+"&verification_code="+ md5 + "&msg_type=1&msg_content="+json+"&platform=android");System.out.println(new String(bytes));
1 0
- Android_开源框架_JPush极光推送
- Android番外02_JPush极光推送集成
- android 框架 极光推送
- App推送java服务端_jpush激光推送
- Android_开源框架_Afinal
- ThinkPHP框架整合极光推送DEMO
- 极光推送集成CI框架中
- (4.2.12.4)【android开源组件】极光推送JPush
- Android_开源框架_Volley实例
- Android_开源框架_Volley实例
- Android_开源框架_NineOldAndroids动画库
- Android_开源框架_Volley实例
- Android_开源框架xUtils详解
- 极光推送
- 极光推送
- 极光推送
- 极光推送
- 极光推送
- JetBrains的pycharm修改IDE的字体大小
- PostgreSQL学习手册(PL/pgSQL过程语言)
- 20131211,微软12月11日发布11个安全补丁
- Android中Bitmap和Drawable
- 【小宝解惑】虚函数和纯虚函数的作用与区别
- Android_开源框架_JPush极光推送
- Android面试题整理【转载】
- 【android-cocos2d-X iconv.h】在android下使用iconv
- Android程序国际化
- AWE /3GB 内存扩展技术
- Modbus通讯协议详细解释
- 【point-2】可在后端规范划加工处理提交的Html 代码片
- 多数据库操作
- C# 如何判断闰年代码