一、首先做一些简单的操作

打开百度首页,然后搜索   ---  极光推送

然后选择打开极光推送的官方网站

打开后,先进行相关的用户名的注册

然后登录进去

在这里面,可以点击文档,然后下载开发所用的开发文档与sdk,或者开发教程视频

然后选择控制台,在控制台中创建一个新的应用

注意,这里添加的应用包名应与所要开发推送功能的应用的包名一致

创建完成后,会生成一个AppKey

二、安卓项目中

首先是将jar包与.os文件引入项目中

然后 在Application中进行相关配制

package com.administrator.pullrefresh;import android.app.Application;import cn.jpush.android.api.JPushInterface;public class MyApplication extends Application {@Overridepublic void onCreate() {super.onCreate();JPushInterface.setDebugMode(true);JPushInterface.init(this);}
}

然后注册一个广播用来监听接收到的推送消息

package com.administrator.pullrefresh;import android.app.NotificationManager;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;import org.json.JSONObject;import cn.jpush.android.api.JPushInterface;public class MyBroadcastReceiver extends BroadcastReceiver {private static final String TAG = "MyReceiver";private NotificationManager nm;@Overridepublic void onReceive(Context context, Intent intent) {if (null == nm) {nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);}Bundle bundle = intent.getExtras();
//        Log.d(TAG, "onReceive - " + intent.getAction() + ", extras: " + AndroidUtil.printBundle(bundle));if (JPushInterface.ACTION_REGISTRATION_ID.equals(intent.getAction())) {Log.d(TAG, "JPush用户注册成功");} else if (JPushInterface.ACTION_MESSAGE_RECEIVED.equals(intent.getAction())) {Log.d(TAG, "接受到推送下来的自定义消息");} else if (JPushInterface.ACTION_NOTIFICATION_RECEIVED.equals(intent.getAction())) {Log.d(TAG, "接受到推送下来的通知");receivingNotification(context,bundle);} else if (JPushInterface.ACTION_NOTIFICATION_OPENED.equals(intent.getAction())) {Log.d(TAG, "用户点击打开了通知");openNotification(context,bundle);} else {Log.d(TAG, "Unhandled intent - " + intent.getAction());}}private void receivingNotification(Context context, Bundle bundle){String title = bundle.getString(JPushInterface.EXTRA_NOTIFICATION_TITLE);Log.d(TAG, " title : " + title);String message = bundle.getString(JPushInterface.EXTRA_ALERT);Log.d(TAG, "message : " + message);String extras = bundle.getString(JPushInterface.EXTRA_EXTRA);Log.d(TAG, "extras : " + extras);} private void openNotification(Context context, Bundle bundle){String extras = bundle.getString(JPushInterface.EXTRA_EXTRA);String myValue = ""; try {//当前的url的值是由,极光推送的服务传递过来的,http://www.itheima.com
//          {
//              url:"http://www.itheima.com";
//          }JSONObject extrasJson = new JSONObject(extras);myValue = extrasJson.optString("url");} catch (Exception e) {Log.w(TAG, "Unexpected: extras is not a valid json", e);return;}/*** 接收到消息后要点击要跳转的页面* 这里是跳转到另一个Activity进行页面信息的显示*/Intent mIntent = new Intent(context, ThisActivity.class);mIntent.putExtra("url", myValue);mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);context.startActivity(mIntent);}
}

那么在信息显示页面中

package com.administrator.pullrefresh;import android.app.Activity;
import android.os.Bundle;
import android.widget.Toast;public class ThisActivity extends Activity {@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.thisactivity);//http://www.ooxx.com/abcd.html--->WebView/*** 这里接收信息* 将接收到的信息进行简单的一个显示操作*/String url = getIntent().getStringExtra("url");Toast.makeText(getApplicationContext(), url, 1).show();}
}

接下来就是配制最重要的清单文件

<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android"package="com.administrator.pullrefresh"><!-- 这里的包名要与极光推送页面中创建应用的包名一至--><!-- Required --><permission android:name="com.administrator.pullrefresh.permission.JPUSH_MESSAGE" android:protectionLevel="signature" /><!-- Required --><uses-permission android:name="com.administrator.pullrefresh.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" /><uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/><uses-permission android:name="android.permission.WRITE_SETTINGS" /> <!--since 1.6.0 --><!-- Optional. Required for location feature --><uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /><uses-permission android:name="android.permission.ACCESS_COARSE_UPDATES" /><uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /><uses-permission android:name="android.permission.CHANGE_WIFI_STATE" /><uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /><uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" /><uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" /><applicationandroid:icon="@mipmap/ic_launcher"android:label="@string/app_name"android:name="com.administrator.pullrefresh.MyApplication"><activityandroid:name="com.administrator.pullrefresh.MainActivity"android:label="@string/app_name"android:theme="@style/AppTheme" ><intent-filter><action android:name="android.intent.action.MAIN" /><category android:name="android.intent.category.LAUNCHER" /></intent-filter></activity><activityandroid:name="com.administrator.pullrefresh.ThisActivity"android:label="@string/app_name"></activity>Required<serviceandroid: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 --><receiverandroid: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.administrator.pullrefresh" /> <!--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><receiverandroid:name="com.administrator.pullrefresh.MyBroadcastReceiver"android:enabled="true" ><intent-filter><action android:name="cn.jpush.android.intent.REGISTRATION" /><action android:name="cn.jpush.android.intent.MESSAGE_RECEIVED" /><action android:name="cn.jpush.android.intent.NOTIFICATION_RECEIVED" /><action android:name="cn.jpush.android.intent.NOTIFICATION_OPENED" /><category android:name="com.administrator.pullrefresh" /></intent-filter></receiver><!-- Required SDK核心功能--><activityandroid: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.administrator.pullrefresh" /></intent-filter></activity><!-- Required SDK核心功能--><serviceandroid:name="cn.jpush.android.service.DownloadService"android:enabled="true"android:exported="false" ></service><!-- Required SDK核心功能--><receiver android:name="cn.jpush.android.service.AlarmReceiver" /><!-- Required. For publish channel feature --><!-- JPUSH_CHANNEL 是为了方便开发者统计APK分发渠道。--><!-- 例如: --><!-- 发到 Google Play 的APK可以设置为 google-play; --><!-- 发到其他市场的 APK 可以设置为 xxx-market。 --><!-- 目前这个渠道统计功能的报表还未开放。--><meta-data android:name="JPUSH_CHANNEL" android:value="developer-default"/><!-- Required. AppKey copied from Portal --><meta-data android:name="JPUSH_APPKEY" android:value="561ec8ebeb6e85d9e2946f53"/></application></manifest>

然后就可以将项目发布到手机上进行相关测试

三、发送消息推送,进行相关测试

测试Demo下载地址

http://download.csdn.net/detail/zl18603543572/9259461

Android极光推送相关推荐

  1. Android 极光推送

    Android 极光推送 效果图 极光推送步骤: 1.首先需要打开极光推送官网:点击打开链接 注册账号并登陆 2.在主页选择SDK下载(如果嫌麻烦可以参考下文中的jcenter 自动集成步骤) 3.在 ...

  2. android 极光推送测试,Android 3分钟带你集成极光推送

    话不多说 首先申请极光的账号,(官方地址:https://www.jiguang.cn) 1561710140829.png 登录完成之后,先看到这个地方 ,我个人比较喜欢用旧版本,这里点击旧版 15 ...

  3. android 极光推送解绑,app集成极光推送笔记(angular js)

    出处:极光推送官方文档以及github上的文档 1.安装 一般使用cordova安装(其他安装方式详见文档),命令行输入: cordova plugin add jpush-phonegap-plug ...

  4. android极光推送 消息穿透广告弹窗,极光推送弹出两次消息,请大佬们帮忙指点迷津...

    本帖最后由 m143 于 2021-3-19 11:55 编辑 1.打开APP ,从后端发送推送,APP连续收到2条推送信息2. 打开APP ,APP在后台运行,从后端发送推送(收到一条消息),点击消 ...

  5. Android 极光推送 自定义通知铃声

    公司使用的推送功能使用的是极光推送,对于普通的通知,极光推送API自动集成了声音的提示,但是对于一些特殊的情况,我们就需要自定义声音提示. 有点坑的是极光并没有提供设置自定通知铃声的接口,所以只能自己 ...

  6. android极光推送原理,【揭秘】极光推送ios、Android消息推送达率的原理

    初接触极光推送的使用者,为了衡量消息推送的质量.经常会纠结到消息的"送达率"这个概念.那么究竟什么是消息送达率呢?或者如何正确理解消息的送达情况呢? 基本概念 先来看与消息送达相关 ...

  7. android极光推送判断消息,通过极光推送给Android所有用户发送推送消息

    https://www.cnblogs.com/yueguanguanyun/p/8485381.html 所需jar包,在maven中添加下列依赖: cn.jpush.api jpush-clien ...

  8. android 极光推送混淆,android 混淆文件的编写(proguard-rules.pro)

    压缩级别 -optimizationpasses 5 -dontusemixedcaseclassnames -dontskipnonpubliclibraryclasses -dontpreveri ...

  9. Android 极光推送SDK集成

    1.创建JPush后台应用 在极光推送的开发者平台创建应用 输入应用包名 在应用信息那里可以看到你的APPKey 点击推送设置,设置包名(这个包名会在你的工程中用到),然后保存即可 2.下载资源 从h ...

最新文章

  1. 十年之后,CV经典教材《计算机视觉:算法与应用》迎来第二版,初稿开放下载...
  2. 矩阵推导后注意力机制居然是这样
  3. maven学习十之myEclipse搭建maven项目总结
  4. c语言四字节转浮点数_C语言浮点书于字节互相转换
  5. arthas 查看哪个方法调用最耗时_阿里巴巴问题排查神器Arthas使用实践
  6. 【sklearn第一讲】scikit-learn 简介
  7. matlab 求积分上限,matlab求解积分上限
  8. 用数字电路和模拟电路搭建出循迹小车(一)
  9. Busybox下tftp命令使用详解
  10. 全球首场神经影像人机对决:AI战胜25位医界“最强大脑”!
  11. 为什么程序员做外包会被瞧不起?
  12. Detected outdated SDK Tools version 0.0.0 when the min version is XXX
  13. 致敬不凡·最美的星火:国产飞腾CPU研发力量
  14. 以CVPR顶会论文为例,探讨AI论文的阅读方法
  15. 【全网最暴力解决方案】使用gdb调试时遭遇“Missing separate debuginfos, use: debuginfo-install glibc....”报错信息
  16. flex中换行符的使用
  17. excel 求去掉最高分最低分后的平均值
  18. 专注做事,竟然也成为我们的稀缺能力
  19. 癌症分类预测-良/恶性乳腺癌肿瘤预测
  20. Android---使用-ContentProvider-无侵入获取-Context,【一步教学,一步到位

热门文章

  1. 剪枝实践:图像检索如何加速和省显存 ?
  2. CVPR 2019 | 旷视提出新型目标检测损失函数:定位更精准
  3. 【OpenCV】OpenCV函数精讲之 -- 图像容器Mat
  4. 姿态估计:人体骨骼关键点检测综述(2016-2020)
  5. 带你自学Python系列(九):一文读懂Python中字典应用原理!
  6. 复练-软考网规-两地三中心
  7. python两数相加有进退位_Leetcode_两数相加_python
  8. 在线翻译英文html文件,copy html是什么意思
  9. id3决策树 鸢尾花 python_机器学习之分类回归树(python实现CART)
  10. mysql 从 a表updateb表_mysql A表自动更新和插入B表的数据