Android studio中极光推送的快速集成
来源:互联网 发布:网络教育金融牌照 编辑:程序博客网 时间:2024/06/05 08:25
前言
极光推送(Jpush)是当下非常流行的一个消息推送框架,其在Android studio中的集成也更加的快速和简单,如果你手速够快,能在极短的时间内完成,这对于单身的程序猿来说并非难事。
1.配置project目录下的gradle
buildscript { repositories { jcenter() } ......}allprojets { repositories { jcenter() }}
2.配置module下的gradle
android { ...... defaultConfig { applicationId "com.xxx.xxx" //JPush上注册的包名. ...... ndk { //选择要添加的对应cpu类型的.so库。 abiFilters 'armeabi', 'armeabi-v7a', 'armeabi-v8a' // 还可以添加 'x86', 'x86_64', 'mips', 'mips64' } manifestPlaceholders = [ JPUSH_PKGNAME : applicationId, JPUSH_APPKEY : "你的appkey", //JPush上注册的包名对应的appkey. JPUSH_CHANNEL : "developer-default", //暂时填写默认值即可. ] ...... } ......}dependencies { ...... compile 'cn.jiguang.sdk:jpush:3.0.3' // 此处以JPush 3.0.3 版本为例。 compile 'cn.jiguang.sdk:jcore:1.1.1' // 此处以JCore 1.1.1 版本为例。 ......}
3.初始化Jpush
public class MyApplication extends Application { @Override public void onCreate() { super.onCreate(); //初始化Jpush JPushInterface.setDebugMode(true); JPushInterface.init(this); }}
此时其实已经可以接收到推送了
但是如果你希望在收到通知后搞出一些其他事情,就需要配置一个广播接受者,在收到广播后作出相应的操作就可以了
4.自定义广播接受者
public class PushReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { Toast.makeText(context,"接收推送",Toast.LENGTH_SHORT).show(); }}
在manifest中配置
<receiver android:name=".receiver.PushReceiver"> <intent-filter> <!--Required 用户注册SDK的intent--> <action android:name="cn.jpush.android.intent.REGISTRATION" /> <!--Required 用户接收SDK消息的intent--> <action android:name="cn.jpush.android.intent.MESSAGE_RECEIVED" /> <!--Required 用户接收SDK通知栏信息的intent--> <action android:name="cn.jpush.android.intent.NOTIFICATION_RECEIVED" /> <!--Required 用户打开自定义通知栏的intent--> <action android:name="cn.jpush.android.intent.NOTIFICATION_OPENED" /> <!-- 接收网络变化 连接/断开 since 1.6.3 --> <action android:name="cn.jpush.android.intent.CONNECTION" /> <category android:name="com.zhuoxin.newsproject11" /> </intent-filter></receiver>
运行效果
大功告成!!!
阅读全文
0 0
- Android studio中极光推送的快速集成
- 简述Android中极光推送的运用步骤
- android studio极光推送的集成
- Android Studio 集成JPUSH推送
- android studio集成极光推送
- Android Studio 集成极光推送
- Android Studio 集成信鸽推送
- Android Studio集成极光推送
- Android Studio集成极光推送
- android studio集成极光推送
- Android 推送:Android Studio 集成Jpush的使用教程
- Android之极光推送SDK集成和基础功能的实现
- Android Studio集成百度推送遇到的坑
- Android 集成极光推送(Android studio)
- Android Studio集成百度云推送
- android studio 集成极光推送(1)
- 使用android studio集成极光推送
- Android Studio jcenter 自动集成极光推送
- 移动端web性能——动画
- 行人检测之Faster-RCNN
- Mysql 笔记(二)
- 集群与负载均衡
- c++ 四种类型转化方式
- Android studio中极光推送的快速集成
- 安全的广播LocalBroadcastManager
- cordova 状态栏颜色的变换
- git原理简介
- JAVA 线程优化及线程池管理
- 《深入理解Java虚拟机》笔记1
- 机器学习——决策树算法的应用
- 【数字图像处理】关于处理灰度图像时总是处理不全的问题
- 让sublime text3支持Vue语法高亮显示