feat: 加入腾讯信鸽支持
This commit is contained in:
parent
480ff37026
commit
7a83b510e9
app
build.gradlegradle/wrapper
settings.gradle@ -6,23 +6,23 @@ plugins {
|
||||
}
|
||||
|
||||
|
||||
sonarqube {
|
||||
properties {
|
||||
//Sonar服务器地址
|
||||
property "sonar.host.url", "http://10.130.14.162:9000/"
|
||||
//Token模式
|
||||
//sonarqube {
|
||||
// properties {
|
||||
// //Sonar服务器地址
|
||||
// property "sonar.host.url", "http://10.130.14.162:9000/"
|
||||
// //Token模式
|
||||
//// property "sonar.login","TRD2022"
|
||||
// //账号密码模式
|
||||
// property "sonar.login","TRD2022"
|
||||
//账号密码模式
|
||||
property "sonar.login","TRD2022"
|
||||
property "sonar.password","TRD2022"
|
||||
property "sonar.sourceEncoding", "UTF-8"
|
||||
property "sonar.projectKey", "Android_DuoApp"
|
||||
property "sonar.projectName", project.name
|
||||
//需要扫描的上传检测代码的模块,可以选择也可以配置哪一些需要或者不需要上传的模块(这里指APP模块下面的java包里面的全部)
|
||||
property "sonar.sources", "src/main/java"
|
||||
property "sonar.projectVersion", project.version
|
||||
}
|
||||
}
|
||||
// property "sonar.password","TRD2022"
|
||||
// property "sonar.sourceEncoding", "UTF-8"
|
||||
// property "sonar.projectKey", "Android_DuoApp"
|
||||
// property "sonar.projectName", project.name
|
||||
// //需要扫描的上传检测代码的模块,可以选择也可以配置哪一些需要或者不需要上传的模块(这里指APP模块下面的java包里面的全部)
|
||||
// property "sonar.sources", "src/main/java"
|
||||
// property "sonar.projectVersion", project.version
|
||||
// }
|
||||
//}
|
||||
//apply plugin: 'com.android.application'
|
||||
//apply plugin: 'kotlin-android'
|
||||
//apply plugin: 'kotlin-kapt'
|
||||
@ -45,7 +45,19 @@ android {
|
||||
// 设置支持的SO库架构(开发者可以根据需要,选择一个或多个平台的so)
|
||||
abiFilters "armeabi", "armeabi-v7a", "arm64-v8a"
|
||||
}
|
||||
|
||||
configurations {
|
||||
cleanedAnnotations
|
||||
// implementation.exclude group: 'org.jetbrains' , module:'annotations'
|
||||
implementation.exclude group: 'com.intellij' , module:'annotations'
|
||||
}
|
||||
|
||||
manifestPlaceholders = [
|
||||
XG_ACCESS_ID : "1580017520",
|
||||
XG_ACCESS_KEY : "ABQZ9Z3PDWXM",
|
||||
]
|
||||
}
|
||||
|
||||
lintOptions {
|
||||
checkReleaseBuilds false
|
||||
// Or, if you prefer, you can continue to check for errors in release builds,
|
||||
@ -81,6 +93,10 @@ android {
|
||||
buildFeatures {
|
||||
viewBinding true
|
||||
}
|
||||
// configurations.all {
|
||||
// all*.exclude group: "com.squareup.okhttp3", module: "okhttp3"
|
||||
// all*.exclude group: "com.squareup.okio", module: "okio"
|
||||
// }
|
||||
}
|
||||
//efs {
|
||||
// //是否对启动过程进程插桩的开关,如果使用自动集成监控则必须开启
|
||||
@ -131,11 +147,11 @@ dependencies {
|
||||
implementation 'com.google.code.gson:gson:2.8.5'
|
||||
implementation 'com.readystatesoftware.chuck:library:1.1.0'
|
||||
|
||||
//retrofit+rxJava
|
||||
implementation 'com.squareup.retrofit2:retrofit:2.5.0'
|
||||
implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
|
||||
//转换器,请求结果转换成Model
|
||||
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.3.0'
|
||||
// //retrofit+rxJava
|
||||
// implementation 'com.squareup.retrofit2:retrofit:2.5.0'
|
||||
// implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
|
||||
// //转换器,请求结果转换成Model
|
||||
// implementation 'com.squareup.retrofit2:adapter-rxjava2:2.3.0'
|
||||
//配合RxJava 使用
|
||||
implementation 'io.reactivex.rxjava2:rxjava:2.2.7'
|
||||
implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
|
||||
@ -207,4 +223,11 @@ dependencies {
|
||||
implementation 'com.elvishew:xlog:1.10.1'
|
||||
// // 百度定位
|
||||
// implementation 'com.baidu.lbsyun:BaiduMapSDK_Location:9.3.7'
|
||||
// 腾讯推送依赖
|
||||
//添加以下依赖
|
||||
implementation 'com.tencent.tpns:tpns:1.4.3.1-release'
|
||||
// 金刚扫描库
|
||||
implementation 'com.tencent.jg:jg:1.1'
|
||||
//推送保活库
|
||||
implementation 'com.github.xuexiangjys.XPush:keeplive:1.0.0'
|
||||
}
|
@ -3,6 +3,23 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
package="com.navinfo.outdoor">
|
||||
|
||||
<!-- 移动推送TPNS自定义权限,用于发送接收广播权限校验(必选)-->
|
||||
<permission
|
||||
android:name="com.navinfo.outdoor.permission.XGPUSH_RECEIVE"
|
||||
android:protectionLevel="signature" />
|
||||
<uses-permission android:name="com.navinfo.outdoor.permission.XGPUSH_RECEIVE" />
|
||||
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
|
||||
|
||||
<uses-permission android:name="com.huawei.android.launcher.permission.CHANGE_BADGE" /><!-- 华为角标 -->
|
||||
<uses-permission android:name="com.vivo.notification.permission.BADGE_ICON" /><!-- VIVO角标权限 -->
|
||||
<uses-permission android:name="android.permission.VIBRATE" /><!--振动器权限,小米推送必须-->
|
||||
|
||||
<uses-permission android:name="android.permission.RECEIVE_USER_PRESENT" /><!--允许应用可以接收点亮屏幕或解锁广播 -->
|
||||
<uses-permission android:name="android.permission.RESTART_PACKAGES" /><!--允许程序结束任务,用户关闭推送服务,推送服务退出 -->
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE " /><!--允许程序写入外部存储,用于保存SDK运行日志 -->
|
||||
<uses-permission android:name="android.permission.GET_TASKS" /><!--允许程序获取任务信息 -->
|
||||
|
||||
|
||||
<uses-permission android:name="android.permission.RECORD_AUDIO" />
|
||||
<uses-permission android:name="android.permission.READ_CALENDAR" /> <!-- <uses-permission android:name="android.permission.WRITE_CALENDAR" /> -->
|
||||
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
|
||||
@ -17,10 +34,6 @@
|
||||
<uses-permission
|
||||
android:name="android.permission.RECEIVE_BOOT_COMPLETED"
|
||||
tools:node="remove" /> <!-- 移除自启动能力 -->
|
||||
<!-- <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> -->
|
||||
<!-- <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> -->
|
||||
<!-- <uses-permission android:name="android.permission.READ_PHONE_STATE" /> -->
|
||||
<!-- <uses-permission android:name="android.permission.INTERNET" /> -->
|
||||
<!-- 腾讯地图 定位权限 -->
|
||||
<!-- 通过GPS得到精确位置 -->
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <!-- 通过网络得到粗略位置 -->
|
||||
@ -36,6 +49,9 @@
|
||||
<uses-permission android:name="android.permission.ACTION_LOCATION_SOURCE_SETTINGS" />
|
||||
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" /> <!-- 支持A-GPS辅助定位 -->
|
||||
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" /> <!-- 用于 log 日志 -->
|
||||
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM"/>
|
||||
<uses-permission android:name="android.permission.WAKE_LOCK" /><!--允许程序在手机屏幕关闭后,后台进程仍然运行,保持推送长链接 -->
|
||||
|
||||
<uses-feature
|
||||
android:name="android.hardware.camera"
|
||||
android:required="true" />
|
||||
@ -227,6 +243,96 @@
|
||||
<meta-data
|
||||
android:name="ScopedStorage"
|
||||
android:value="true" />
|
||||
|
||||
<!-- 设置推送节点为上海 -->
|
||||
<meta-data
|
||||
android:name="XG_SERVER_SUFFIX"
|
||||
android:value="tpns.sh.tencent.com" />
|
||||
<uses-library android:name="org.apache.http.legacy"
|
||||
android:required="false"/>
|
||||
|
||||
<!-- <!– 【必须】 信鸽receiver广播接收 –>-->
|
||||
<!-- <receiver-->
|
||||
<!-- android:name="com.tencent.android.tpush.XGPushReceiver"-->
|
||||
<!-- android:exported="false"-->
|
||||
<!-- android:process=":xg_vip_service">-->
|
||||
<!-- <intent-filter android:priority="0x7fffffff">-->
|
||||
<!-- <!– 【必须】 信鸽SDK的内部广播 –>-->
|
||||
<!-- <action android:name="com.tencent.android.xg.vip.action.SDK" />-->
|
||||
<!-- <action android:name="com.tencent.android.xg.vip.action.INTERNAL_PUSH_MESSAGE" />-->
|
||||
<!-- <action android:name="com.tencent.android.xg.vip.action.ACTION_SDK_KEEPALIVE" />-->
|
||||
<!-- </intent-filter>-->
|
||||
<!-- </receiver>-->
|
||||
|
||||
|
||||
<!-- <!– 【必须】移动推送 TPNS service –>-->
|
||||
<!-- <service-->
|
||||
<!-- android:name="com.tencent.android.tpush.service.XGVipPushService"-->
|
||||
<!-- android:exported="false"-->
|
||||
<!-- android:process=":xg_vip_service">-->
|
||||
<!-- </service>-->
|
||||
|
||||
|
||||
<!-- <!– 【必须】通知 service ,android:name 部分改为包名.XGVIP_PUSH_ACTION –>-->
|
||||
<!-- <service android:name="com.tencent.android.tpush.rpc.XGRemoteService"-->
|
||||
<!-- android:exported="false">-->
|
||||
<!-- <intent-filter>-->
|
||||
<!-- <!– 【必须】请修改为当前APP名包.XGVIP_PUSH_ACTION –>-->
|
||||
<!-- <action android:name="com.navinfo.outdoor.XGVIP_PUSH_ACTION" />-->
|
||||
<!-- </intent-filter>-->
|
||||
<!-- </service>-->
|
||||
|
||||
|
||||
<!-- <!– 【必须】【注意】authorities 修改为包名.XGVIP_PUSH_AUTH –>-->
|
||||
<!-- <provider-->
|
||||
<!-- android:name="com.tencent.android.tpush.XGPushProvider"-->
|
||||
<!-- android:authorities="com.navinfo.outdoor.XGVIP_PUSH_AUTH" />-->
|
||||
|
||||
|
||||
<!-- <!– 【必须】【注意】authorities 修改为包名.TPUSH_PROVIDER –>-->
|
||||
<!-- <provider-->
|
||||
<!-- android:name="com.tencent.android.tpush.SettingsContentProvider"-->
|
||||
<!-- android:authorities="com.navinfo.outdoor.TPUSH_PROVIDER" />-->
|
||||
|
||||
|
||||
<!-- <!– 【可选】用于增强保活能力 –>-->
|
||||
<!-- <provider-->
|
||||
<!-- android:name="com.tencent.android.tpush.XGVipPushKAProvider"-->
|
||||
<!-- android:authorities="com.navinfo.outdoor.AUTH_XGPUSH_KEEPALIVE"-->
|
||||
<!-- android:exported="true" />-->
|
||||
<!-- <!– MQTT START –>-->
|
||||
<!-- <service android:exported="false"-->
|
||||
<!-- android:process=":xg_vip_service"-->
|
||||
<!-- android:name="com.tencent.tpns.mqttchannel.services.MqttService" />-->
|
||||
|
||||
|
||||
<!-- <provider-->
|
||||
<!-- android:exported="false"-->
|
||||
<!-- android:name="com.tencent.tpns.baseapi.base.SettingsContentProvider"-->
|
||||
<!-- android:authorities="com.navinfo.outdoor.XG_SETTINGS_PROVIDER" />-->
|
||||
<!-- <!– MQTT END–>-->
|
||||
|
||||
<!-- 【可选】APP实现的Receiver,用于接收消息透传和操作结果的回调,请根据需要添加 -->
|
||||
<!-- YOUR_PACKAGE_PATH.CustomPushReceiver需要改为自己的Receiver: -->
|
||||
<receiver android:name="com.navinfo.outdoor.receiver.MessageReceiver"
|
||||
android:exported="false">
|
||||
<intent-filter>
|
||||
<!-- 接收消息透传 -->
|
||||
<action android:name="com.tencent.android.xg.vip.action.PUSH_MESSAGE" />
|
||||
<!-- 监听注册、反注册、设置/删除标签、通知被点击等处理结果 -->
|
||||
<action android:name="com.tencent.android.xg.vip.action.FEEDBACK" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
<!-- 【必须】 请修改为 APP 的 AccessId,“15”开头的10位数字,中间没空格 -->
|
||||
<meta-data
|
||||
android:name="XG_V2_ACCESS_ID"
|
||||
android:value="1580017520" />
|
||||
<!-- 【必须】 请修改为APP的AccessKey,“A”开头的12位字符串,中间没空格 -->
|
||||
<meta-data
|
||||
android:name="XG_V2_ACCESS_KEY"
|
||||
android:value="ABQZ9Z3PDWXM" />
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
@ -93,6 +93,8 @@ import com.tencent.tencentmap.mapsdk.maps.model.PolylineOptions;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.TencentMapGestureListener;
|
||||
import com.umeng.commonsdk.internal.crash.UMCrashManager;
|
||||
import com.umeng.umcrash.UMCrash;
|
||||
|
||||
import org.locationtech.jts.geom.Coordinate;
|
||||
import org.locationtech.jts.geom.Geometry;
|
||||
import org.locationtech.jts.geom.LineString;
|
||||
import org.locationtech.jts.geom.MultiLineString;
|
||||
@ -684,6 +686,11 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen
|
||||
for (int i = 0; i < multiLineString.getNumGeometries(); i++) {
|
||||
lineStringList.add((LineString) multiLineString.getGeometryN(i));
|
||||
}
|
||||
}
|
||||
else if ("Point".equals(taskGeometry.getGeometryType())) {
|
||||
Coordinate pointCoor = taskGeometry.getCoordinate();
|
||||
Coordinate pointCoor2 = new Coordinate(pointCoor.x, pointCoor.y+0.00001);
|
||||
lineStringList.add(GeometryTools.getLineStrinGeo(new Coordinate[]{pointCoor, pointCoor2}));
|
||||
} else {
|
||||
lineStringList.add((LineString) taskGeometry);
|
||||
}
|
||||
|
55
app/src/main/java/com/navinfo/outdoor/api/KeepLiveUtils.java
Normal file
55
app/src/main/java/com/navinfo/outdoor/api/KeepLiveUtils.java
Normal file
@ -0,0 +1,55 @@
|
||||
package com.navinfo.outdoor.api;
|
||||
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
import com.github.lazylibrary.util.AppUtils;
|
||||
import com.navinfo.outdoor.R;
|
||||
import com.xuexiang.keeplive.KeepLive;
|
||||
import com.xuexiang.keeplive.config.ForegroundNotification;
|
||||
import com.xuexiang.keeplive.config.ForegroundNotificationClickListener;
|
||||
import com.xuexiang.keeplive.config.KeepLiveService;
|
||||
|
||||
public class KeepLiveUtils {
|
||||
/**
|
||||
* 初始化保活,配置完成后即可实现程序的保活
|
||||
*/
|
||||
private void initKeepLive(Application application) {
|
||||
//定义前台服务的默认样式。即标题、描述和图标
|
||||
ForegroundNotification notification = new ForegroundNotification("推送服务", "推送服务正在运行中...", R.mipmap.ic_launcher,
|
||||
//定义前台服务的通知点击事件
|
||||
new ForegroundNotificationClickListener() {
|
||||
@Override
|
||||
public void onNotificationClick(Context context, Intent intent) {
|
||||
//可以做一些唤醒程序的操作,这里只是简单地启动了应用
|
||||
AppUtils.launchApp(application.getPackageName());
|
||||
}
|
||||
})
|
||||
//要想不显示通知,可以设置为false,默认是false
|
||||
.setIsShow(true);
|
||||
//启动保活服务
|
||||
KeepLive.startWork(application, KeepLive.RunMode.ENERGY, notification,
|
||||
//你需要保活的服务,如socket连接、定时任务等,建议不用匿名内部类的方式在这里写
|
||||
new KeepLiveService() {
|
||||
/**
|
||||
* 运行中
|
||||
* 由于服务可能会多次自动启动,该方法可能重复调用
|
||||
*/
|
||||
@Override
|
||||
public void onWorking() {
|
||||
//可以做一些保活的处理,比如说恢复推送连接等
|
||||
}
|
||||
|
||||
/**
|
||||
* 服务终止
|
||||
* 由于服务可能会被多次终止,该方法可能重复调用,需同onWorking配套使用,如注册和注销broadcast
|
||||
*/
|
||||
@Override
|
||||
public void onStop() {
|
||||
//该回调方法可能会不回调
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
@ -10,6 +10,7 @@ import android.util.Log;
|
||||
|
||||
import androidx.lifecycle.ProcessLifecycleOwner;
|
||||
|
||||
import com.elvishew.xlog.XLog;
|
||||
import com.kongzue.dialogx.DialogX;
|
||||
import com.kongzue.dialogx.style.MIUIStyle;
|
||||
import com.kongzue.dialogx.style.MaterialStyle;
|
||||
@ -21,6 +22,9 @@ import com.lzy.okgo.cookie.store.DBCookieStore;
|
||||
import com.lzy.okgo.interceptor.HttpLoggingInterceptor;
|
||||
import com.lzy.okgo.model.HttpHeaders;
|
||||
import com.navinfo.outdoor.util.CrashHandler;
|
||||
import com.tencent.android.tpush.XGIOperateCallback;
|
||||
import com.tencent.android.tpush.XGPushConfig;
|
||||
import com.tencent.android.tpush.XGPushManager;
|
||||
import com.tencent.map.navi.TencentNavi;
|
||||
import com.tencent.navi.surport.utils.DeviceUtils;
|
||||
import com.tencent.tencentmap.mapsdk.maps.TencentMapInitializer;
|
||||
@ -70,6 +74,22 @@ public class UserApplication extends Application {
|
||||
DialogX.init(this);
|
||||
DialogX.globalStyle = new MIUIStyle();
|
||||
CrashHandler.getInstance().init();
|
||||
// 注册腾讯推送
|
||||
XGPushConfig.enableDebug(this,true);
|
||||
XGPushManager.registerPush(this, new XGIOperateCallback() {
|
||||
@Override
|
||||
public void onSuccess(Object data, int flag) {
|
||||
//token在设备卸载重装的时候有可能会变
|
||||
Log.d("TPush", "注册成功,设备token为:" + data);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onFail(Object data, int errCode, String msg) {
|
||||
Log.d("TPush", "注册失败,错误码:" + errCode + ",错误信息:" + msg);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public static UserApplication getUserApplication() {
|
||||
|
@ -237,7 +237,6 @@ public class CommonRequestSend<T extends CommonResponseBase> {
|
||||
builder.writeTimeout(time, TimeUnit.SECONDS);
|
||||
//全局的连接超时时间
|
||||
builder.connectTimeout(time, TimeUnit.SECONDS);
|
||||
builder.callTimeout(time, TimeUnit.SECONDS);
|
||||
OkGo.getInstance().init(UserApplication.getUserApplication()).setOkHttpClient(builder.build())
|
||||
//全局统一缓存模式,默认不使用缓存,可以不传
|
||||
.setCacheMode(CacheMode.NO_CACHE)
|
||||
|
@ -49,8 +49,6 @@ import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Objects;
|
||||
|
||||
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
|
||||
|
||||
/**
|
||||
* 记录-已提交
|
||||
*/
|
||||
|
@ -1,16 +1,17 @@
|
||||
package com.navinfo.outdoor.http;
|
||||
|
||||
public class HttpInterface {
|
||||
// public static final String IP = "http://172.23.138.133:9999/m4";//测试接口-IP
|
||||
// public static final String IP = "http://dtxbmaps.navinfo.com/dtxb/dev/m4";//开发接口-外网
|
||||
// 开发
|
||||
// public static final String IP = "http://dtxbmaps.navinfo.com/dtxb/dev/m4";//开发地址
|
||||
// public static final String IP_UPLOAD = "http://dtxbmaps.navinfo.com/dtxb/dev/m4";//开发接口-数据上传
|
||||
|
||||
// public static final String IP = "http://120.92.212.218/dtxb/test/m4";//金山云接口地址
|
||||
// public static final String IP_UPLOAD = "http://120.131.12.158/dtxb/test/m4";//金山云接口地址-数据上传
|
||||
public static final String IP = "http://dtxbmaps.navinfo.com/dtxb/test/m4";//正式环境接口
|
||||
public static final String IP_UPLOAD = "http://dtxbmaps.navinfo.com/dtxb/test/m4";//正式环境接口
|
||||
public static final String IP1 = "http://dtxbmaps.navinfo.com/dtxb/test/m4";//测试接口-外网
|
||||
public static final String IP2 = "http://dtxbmaps.navinfo.com/dtxb/m4";//正式接口
|
||||
public static final String IP4 = "http://10.130.23.166/dtxb/jinshan/m4";//心榕给的测试地址
|
||||
// 测试
|
||||
public static final String IP = "http://dtxbmaps.navinfo.com/dtxb/test/m4";//测试环境接口
|
||||
public static final String IP_UPLOAD = "http://dtxbmaps.navinfo.com/dtxb/test/m4";//测试环境接口-数据上传
|
||||
|
||||
// 生产
|
||||
// public static final String IP = "http://dtxbmaps.navinfo.com/dtxb/m4";//生产地址
|
||||
// public static final String IP_UPLOAD = "http://dtxbmaps.navinfo.com/dtxb/m4";//生产地址-数据上传
|
||||
public static final String USER_PATH = "/user/";//我的
|
||||
public static final String MSG_LIST_PATH = "/msgList/";//发现
|
||||
public static final String USER_LOGIN_PATH = "/userlogin/";//登录
|
||||
|
@ -0,0 +1,276 @@
|
||||
package com.navinfo.outdoor.receiver;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.elvishew.xlog.XLog;
|
||||
import com.tencent.android.tpush.NotificationAction;
|
||||
import com.tencent.android.tpush.XGPushBaseReceiver;
|
||||
import com.tencent.android.tpush.XGPushClickedResult;
|
||||
import com.tencent.android.tpush.XGPushRegisterResult;
|
||||
import com.tencent.android.tpush.XGPushShowedResult;
|
||||
import com.tencent.android.tpush.XGPushTextMessage;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
public class MessageReceiver extends XGPushBaseReceiver {
|
||||
public static final String UPDATE_LISTVIEW_ACTION = "com.qq.xgdemo.activity.UPDATE_LISTVIEW";
|
||||
public static final String TEST_ACTION = "com.qq.xgdemo.activity.TEST_ACTION";
|
||||
public static final String LogTag = "xg.test";
|
||||
|
||||
/**
|
||||
* 消息透传处理
|
||||
* @param context
|
||||
* @param message 解析自定义的 JSON
|
||||
*/
|
||||
@Override
|
||||
public void onTextMessage(Context context, XGPushTextMessage message) {
|
||||
String text = "onTextMessage:" + message.toString();
|
||||
// 获取自定义key-value
|
||||
String customContent = message.getCustomContent();
|
||||
if (customContent != null && customContent.length() != 0) {
|
||||
try {
|
||||
JSONObject obj = new JSONObject(customContent);
|
||||
// key1为前台配置的key
|
||||
if (!obj.isNull("key")) {
|
||||
String value = obj.getString("key");
|
||||
XLog.d("get custom value:" + value);
|
||||
}
|
||||
// ...
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
// APP自主处理消息的过程...
|
||||
XLog.d(text);
|
||||
show(context, text);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通知展示
|
||||
* @param context
|
||||
* @param notifiShowedRlt 包含通知的内容
|
||||
*/
|
||||
@Override
|
||||
public void onNotificationShowedResult(Context context, XGPushShowedResult notifiShowedRlt) {
|
||||
if (context == null || notifiShowedRlt == null) {
|
||||
return;
|
||||
}
|
||||
XLog.d("onNotificationShowedResult:"+notifiShowedRlt.getContent());
|
||||
// XGNotification notific = new XGNotification();
|
||||
// notific.setMsg_id(notifiShowedRlt.getMsgId());
|
||||
// notific.setTitle(notifiShowedRlt.getTitle());
|
||||
// notific.setContent(notifiShowedRlt.getContent());
|
||||
// // notificationActionType==1为Activity,2为url,3为intent
|
||||
// notific.setNotificationActionType(notifiShowedRlt
|
||||
// .getNotificationActionType());
|
||||
// // Activity,url,intent都可以通过getActivity()获得
|
||||
// notific.setActivity(notifiShowedRlt.getActivity());
|
||||
// notific.setUpdate_time(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
|
||||
// .format(Calendar.getInstance().getTime()));
|
||||
// NotificationService.getInstance(context).save(notific);
|
||||
//
|
||||
// Intent testIntent = new Intent(TEST_ACTION);
|
||||
// if (notifiShowedRlt.getTitle().equals(Constants.LOCAL_NOTIFICATION_TITLE)) {
|
||||
// testIntent.putExtra("step", Constants.TEST_LOCAL_NOTIFICATION);
|
||||
// } else {
|
||||
// testIntent.putExtra("step", Constants.TEST_NOTIFICATION);
|
||||
// }
|
||||
// context.sendBroadcast(testIntent);
|
||||
//
|
||||
// Intent viewIntent = new Intent(UPDATE_LISTVIEW_ACTION);
|
||||
// context.sendBroadcast(viewIntent);
|
||||
// show(context, "您有1条新消息, " + "通知被展示 , " + notifiShowedRlt.toString());
|
||||
// XLog.d("您有1条新消息, " + "通知被展示 , " + notifiShowedRlt.toString() + ", PushChannel:" + notifiShowedRlt.getPushChannel());
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册回调
|
||||
* @param context
|
||||
* @param errorCode 0 为成功,其它为错误码
|
||||
*/
|
||||
@Override
|
||||
public void onRegisterResult(Context context, int errorCode, XGPushRegisterResult message) {
|
||||
if (context == null || message == null) {
|
||||
return;
|
||||
}
|
||||
String text = "";
|
||||
if (errorCode == XGPushBaseReceiver.SUCCESS) {
|
||||
// 在这里拿token
|
||||
String token = message.getToken();
|
||||
text = "注册成功1. token:" + token;
|
||||
} else {
|
||||
text = message + "注册失败,错误码:" + errorCode;
|
||||
}
|
||||
XLog.d(text);
|
||||
show(context, text);
|
||||
}
|
||||
|
||||
/**
|
||||
* 反注册回调
|
||||
* @param context
|
||||
* @param errorCode 0 为成功,其它为错误码
|
||||
*/
|
||||
@Override
|
||||
public void onUnregisterResult(Context context, int errorCode) {
|
||||
if (context == null) {
|
||||
return;
|
||||
}
|
||||
String text = "";
|
||||
if (errorCode == XGPushBaseReceiver.SUCCESS) {
|
||||
text = "反注册成功";
|
||||
} else {
|
||||
text = "反注册失败" + errorCode;
|
||||
}
|
||||
XLog.d(text);
|
||||
show(context, text);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置标签回调
|
||||
* @param context
|
||||
* @param errorCode 0 为成功,其它为错误码
|
||||
* @param tagName 设置的 TAG
|
||||
*/
|
||||
@Override
|
||||
public void onSetTagResult(Context context, int errorCode, String tagName) {
|
||||
if (context == null) {
|
||||
return;
|
||||
}
|
||||
String text = "";
|
||||
if (errorCode == XGPushBaseReceiver.SUCCESS) {
|
||||
text = "\"" + tagName + "\"设置成功";
|
||||
} else {
|
||||
text = "\"" + tagName + "\"设置失败,错误码:" + errorCode;
|
||||
}
|
||||
XLog.d(text);
|
||||
show(context, text);
|
||||
|
||||
// Intent testIntent = new Intent(TEST_ACTION);
|
||||
// testIntent.putExtra("step", Constants.TEST_SET_TAG);
|
||||
// context.sendBroadcast(testIntent);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除标签的回调
|
||||
* @param context
|
||||
* @param errorCode 0 为成功,其它为错误码
|
||||
* @param tagName 设置的 TAG
|
||||
*/
|
||||
@Override
|
||||
public void onDeleteTagResult(Context context, int errorCode, String tagName) {
|
||||
if (context == null) {
|
||||
return;
|
||||
}
|
||||
String text = "";
|
||||
if (errorCode == XGPushBaseReceiver.SUCCESS) {
|
||||
text = "\"" + tagName + "\"删除成功";
|
||||
} else {
|
||||
text = "\"" + tagName + "\"删除失败,错误码:" + errorCode;
|
||||
}
|
||||
XLog.d(text);
|
||||
show(context, text);
|
||||
|
||||
// Intent testIntent = new Intent(TEST_ACTION);
|
||||
// testIntent.putExtra("step", Constants.TEST_DEL_TAG);
|
||||
// context.sendBroadcast(testIntent);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置账号回调
|
||||
* @param context
|
||||
* @param errorCode 0 为成功,其它为错误码
|
||||
* @param account 设置的账号
|
||||
*/
|
||||
@Override
|
||||
public void onSetAccountResult(Context context, int errorCode, String account) {
|
||||
// Intent testIntent = new Intent(TEST_ACTION);
|
||||
// testIntent.putExtra("step", Constants.TEST_SET_ACCOUNT);
|
||||
// context.sendBroadcast(testIntent);
|
||||
XLog.d("onSetAccountResult:"+errorCode+"-"+account);
|
||||
show(context, errorCode+":"+account);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除账号回调
|
||||
* @param context
|
||||
* @param errorCode 0 为成功,其它为错误码
|
||||
* @param account 设置的账号
|
||||
*/
|
||||
@Override
|
||||
public void onDeleteAccountResult(Context context, int errorCode, String account) {
|
||||
// Intent testIntent = new Intent(TEST_ACTION);
|
||||
// testIntent.putExtra("step", Constants.TEST_DEL_ACCOUNT);
|
||||
// context.sendBroadcast(testIntent);
|
||||
XLog.d("onDeleteAccountResult:"+errorCode+"-"+account);
|
||||
show(context, errorCode+":"+account);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSetAttributeResult(Context context, int i, String s) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDeleteAttributeResult(Context context, int i, String s) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onQueryTagsResult(Context context, int errorCode, String data, String operateName) {
|
||||
XLog.i("action - onQueryTagsResult, errorCode:" + errorCode + ", operateName:" + operateName + ", data: " + data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通知点击回调 actionType=1为该消息被清除,actionType=0为该消息被点击
|
||||
* @param context
|
||||
* @param message 包含被点击通知的内容
|
||||
*/
|
||||
@Override
|
||||
public void onNotificationClickedResult(Context context, XGPushClickedResult message) {
|
||||
if (context == null || message == null) {
|
||||
return;
|
||||
}
|
||||
String text = "";
|
||||
if (message.getActionType() == NotificationAction.clicked.getType()) {
|
||||
// 通知在通知栏被点击啦。。。。。
|
||||
// APP自己处理点击的相关动作
|
||||
// 这个动作可以在activity的onResume也能监听,请看第3点相关内容
|
||||
text = "通知被打开 :" + message;
|
||||
} else if (message.getActionType() == NotificationAction.delete.getType()) {
|
||||
// 通知被清除啦。。。。
|
||||
// APP自己处理通知被清除后的相关动作
|
||||
text = "通知被清除 :" + message;
|
||||
}
|
||||
Toast.makeText(context, "广播接收到通知被点击:" + message.toString(),
|
||||
Toast.LENGTH_SHORT).show();
|
||||
// 获取自定义key-value
|
||||
String customContent = message.getCustomContent();
|
||||
if (customContent != null && customContent.length() != 0) {
|
||||
try {
|
||||
JSONObject obj = new JSONObject(customContent);
|
||||
// key1为前台配置的key
|
||||
if (!obj.isNull("key")) {
|
||||
String value = obj.getString("key");
|
||||
XLog.d("get custom value:" + value);
|
||||
}
|
||||
// ...
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
// APP自主处理的过程。。。
|
||||
XLog.d(text);
|
||||
show(context, text);
|
||||
}
|
||||
|
||||
private void show(Context context, String text) {
|
||||
Toast.makeText(context, text, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
}
|
14
app/tpns-configs.json
Normal file
14
app/tpns-configs.json
Normal file
@ -0,0 +1,14 @@
|
||||
{
|
||||
"tpns": {
|
||||
"access_id": "1580017520",
|
||||
"access_key": "ABQZ9Z3PDWXM"
|
||||
},
|
||||
"com.navinfo.outdoor": {
|
||||
"channel": {
|
||||
"enable": true
|
||||
}
|
||||
},
|
||||
"debug": true,
|
||||
"version": "1.4.3.1-release",
|
||||
"upgrade": true
|
||||
}
|
52
build.gradle
52
build.gradle
@ -3,6 +3,7 @@ buildscript {
|
||||
ext.anko_version = '0.10.1'//扩展库版本
|
||||
ext.kotlin_version = '1.5.10'
|
||||
repositories {
|
||||
mavenCentral()
|
||||
//友盟 检测bug
|
||||
//腾讯地图
|
||||
maven{
|
||||
@ -19,7 +20,6 @@ buildscript {
|
||||
//友盟 检测bug
|
||||
maven { url 'https://repo1.maven.org/maven2/' }
|
||||
jcenter()
|
||||
mavenCentral()
|
||||
google()
|
||||
maven{
|
||||
url "https://maven.google.com/"
|
||||
@ -36,31 +36,31 @@ buildscript {
|
||||
|
||||
}
|
||||
|
||||
allprojects {
|
||||
repositories {
|
||||
//友盟 检测bug
|
||||
//腾讯地图
|
||||
maven{
|
||||
url "https://oss.sonatype.org/content/groups/public"
|
||||
}
|
||||
maven { url 'https://repo1.maven.org/maven2/' }
|
||||
maven{ url 'https://maven.aliyun.com/repository/google'}
|
||||
maven{ url 'https://maven.aliyun.com/repository/gradle-plugin'}
|
||||
maven{ url 'https://maven.aliyun.com/repository/public'}
|
||||
maven{ url 'https://maven.aliyun.com/repository/jcenter'}
|
||||
maven{ url 'https://maven.aliyun.com/nexus/content/groups/public/'}
|
||||
maven { url "https://jitpack.io" }
|
||||
maven { url "https://repo.spring.io/libs-release/" }
|
||||
//友盟 检测bug
|
||||
maven { url 'https://repo1.maven.org/maven2/' }
|
||||
jcenter()
|
||||
mavenCentral()
|
||||
google()
|
||||
maven{
|
||||
url "https://maven.google.com/"
|
||||
}
|
||||
}
|
||||
}
|
||||
//allprojects {
|
||||
// repositories {
|
||||
// mavenCentral()
|
||||
// //友盟 检测bug
|
||||
// //腾讯地图
|
||||
// maven{
|
||||
// url "https://oss.sonatype.org/content/groups/public"
|
||||
// }
|
||||
// maven { url 'https://repo1.maven.org/maven2/' }
|
||||
// maven{ url 'https://maven.aliyun.com/repository/google'}
|
||||
// maven{ url 'https://maven.aliyun.com/repository/gradle-plugin'}
|
||||
// maven{ url 'https://maven.aliyun.com/repository/public'}
|
||||
// maven{ url 'https://maven.aliyun.com/repository/jcenter'}
|
||||
// maven{ url 'https://maven.aliyun.com/nexus/content/groups/public/'}
|
||||
// maven { url "https://jitpack.io" }
|
||||
// maven { url "https://repo.spring.io/libs-release/" }
|
||||
// //友盟 检测bug
|
||||
// maven { url 'https://repo1.maven.org/maven2/' }
|
||||
// jcenter()
|
||||
// google()
|
||||
// maven{
|
||||
// url "https://maven.google.com/"
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
task clean(type: Delete) {
|
||||
delete rootProject.buildDir
|
||||
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,6 +1,6 @@
|
||||
#Tue Jul 18 13:25:30 CST 2023
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
@ -1 +1,56 @@
|
||||
pluginManagement {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
//友盟 检测bug
|
||||
//腾讯地图
|
||||
maven{
|
||||
url "https://oss.sonatype.org/content/groups/public"
|
||||
}
|
||||
maven { url 'https://repo1.maven.org/maven2/' }
|
||||
maven{ url 'https://maven.aliyun.com/repository/google'}
|
||||
maven{ url 'https://maven.aliyun.com/repository/gradle-plugin'}
|
||||
maven{ url 'https://maven.aliyun.com/repository/public'}
|
||||
maven{ url 'https://maven.aliyun.com/repository/jcenter'}
|
||||
maven{ url 'https://maven.aliyun.com/nexus/content/groups/public/'}
|
||||
maven { url "https://jitpack.io" }
|
||||
maven { url "https://repo.spring.io/libs-release/" }
|
||||
//友盟 检测bug
|
||||
maven { url 'https://repo1.maven.org/maven2/' }
|
||||
jcenter()
|
||||
google()
|
||||
maven{
|
||||
url "https://maven.google.com/"
|
||||
}
|
||||
gradlePluginPortal()
|
||||
}
|
||||
}
|
||||
dependencyResolutionManagement {
|
||||
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
|
||||
repositories {
|
||||
mavenCentral()
|
||||
//友盟 检测bug
|
||||
//腾讯地图
|
||||
maven{
|
||||
url "https://oss.sonatype.org/content/groups/public"
|
||||
}
|
||||
maven { url 'https://repo1.maven.org/maven2/' }
|
||||
maven{ url 'https://maven.aliyun.com/repository/google'}
|
||||
maven{ url 'https://maven.aliyun.com/repository/gradle-plugin'}
|
||||
maven{ url 'https://maven.aliyun.com/repository/public'}
|
||||
maven{ url 'https://maven.aliyun.com/repository/jcenter'}
|
||||
maven{ url 'https://maven.aliyun.com/nexus/content/groups/public/'}
|
||||
maven { url "https://jitpack.io" }
|
||||
maven { url "https://repo.spring.io/libs-release/" }
|
||||
//友盟 检测bug
|
||||
maven { url 'https://repo1.maven.org/maven2/' }
|
||||
jcenter()
|
||||
google()
|
||||
maven{
|
||||
url "https://maven.google.com/"
|
||||
}
|
||||
gradlePluginPortal()
|
||||
|
||||
}
|
||||
}
|
||||
rootProject.name = "NavinfoOutDoor"
|
||||
include ':app', ':xrecyclerview', ":ocr"
|
Loading…
x
Reference in New Issue
Block a user