update:2020.06.17

fix:优化没有信息时标签不显示
add:
This commit is contained in:
2020-06-17 16:53:52 +08:00
parent 780fb8561b
commit 988c1c9389
7 changed files with 82 additions and 65 deletions

View File

@@ -105,6 +105,42 @@ public class MyJPushReceiver extends BroadcastReceiver {
return 0;
}
@Override
public void onReceive(Context context, Intent intent) {
mContext = context;
Bundle bundle = intent.getExtras();
if (JPushInterface.ACTION_REGISTRATION_ID.equals(intent.getAction())) {
String regId = bundle.getString(JPushInterface.EXTRA_REGISTRATION_ID);
Log.e(TAG, "[MyReceiver] 接收Registration Id : " + regId);
//send the Registration Id to your server...
} else if (JPushInterface.ACTION_MESSAGE_RECEIVED.equals(intent.getAction())) {
// ToastTool.show("[MyReceiver] 接收到推送下来的自定义消息: " + bundle.getString(JPushInterface.EXTRA_MESSAGE)
// + "---" + bundle.getString(JPushInterface.EXTRA_TITLE) + "---" + bundle.getString(JPushInterface.EXTRA_CONTENT_TYPE)
// + "---" + bundle.getString(JPushInterface.EXTRA_EXTRA) + "----" + bundle.getString("package_name"));
// Log.e(TAG, "[MyReceiver] 接收到推送下来的自定义消息: " + bundle.getString(JPushInterface.EXTRA_MESSAGE)
// + "---" + bundle.getString(JPushInterface.EXTRA_TITLE) + "---" + bundle.getString(JPushInterface.EXTRA_CONTENT_TYPE)
// + "---" + bundle.getString(JPushInterface.EXTRA_EXTRA) + "----" + bundle.getString("package_name"));
processCustomMessage(context, bundle);//屏蔽推送
} else if (JPushInterface.ACTION_NOTIFICATION_RECEIVED.equals(intent.getAction())) {
Log.e(TAG, "[MyReceiver] 接收到推送下来的通知" + bundle.getString(JPushInterface.EXTRA_EXTRA));
// doDownloadAndInstall(bundle.getString(JPushInterface.EXTRA_EXTRA));
// LogUtils.e(getBatteryLevel()+"-0-iweroiwerewefeerer-----------");
int notifactionId = bundle.getInt(JPushInterface.EXTRA_NOTIFICATION_ID);
Log.e(TAG, "[MyReceiver] 接收到推送下来的通知的ID: " + notifactionId);
} else if (JPushInterface.ACTION_NOTIFICATION_OPENED.equals(intent.getAction())) {
Log.e(TAG, "[MyReceiver] 用户点击打开了通知");
} else if (JPushInterface.ACTION_RICHPUSH_CALLBACK.equals(intent.getAction())) {
Log.e(TAG, "[MyReceiver] 用户收到到RICH PUSH CALLBACK: " + bundle.getString(JPushInterface.EXTRA_EXTRA));
//在这里根据 JPushInterface.EXTRA_EXTRA 的内容处理代码比如打开新的Activity 打开一个网页等..
} else if (JPushInterface.ACTION_CONNECTION_CHANGE.equals(intent.getAction())) {
boolean connected = intent.getBooleanExtra(JPushInterface.EXTRA_CONNECTION_CHANGE, false);
Log.e(TAG, "[MyReceiver]" + intent.getAction() + " connected state change to " + connected);
} else {
Log.e(TAG, "[MyReceiver] Unhandled intent - " + intent.getAction());
}
}
private void processCustomMessage(final Context context, Bundle bundle) {
String message = bundle.getString(JPushInterface.EXTRA_MESSAGE);
String title = bundle.getString(JPushInterface.EXTRA_TITLE);
@@ -178,15 +214,22 @@ public class MyJPushReceiver extends BroadcastReceiver {
MyApplication.sendAppUsedTime(random, sendType);
break;
case GET_FORCEDOWNLOADURL:
com.alibaba.fastjson.JSONObject URI = JSON.parseObject(extras);
String versionCode = URI.getString("version_code");
String url = URI.getString("url");
if (TextUtils.isEmpty(extras)) {
Log.e("mjsheng", "settingNetControl extras is null");
return;
}
com.alibaba.fastjson.JSONObject extra = JSON.parseObject(extras);
String app_name=extra.getString("app_name");
String app_package=extra.getString("package");
String url = extra.getString("url");
int versionCode = extra.getInteger("version_code");
com.alibaba.fastjson.JSONObject packageObj = new com.alibaba.fastjson.JSONObject();
packageObj.put("app_name", "教管易");
packageObj.put("app_package", "com.jiaoguanyi.store");
packageObj.put("app_name", app_name);
packageObj.put("app_package", app_package);
Aria.download(this)
.load(url) //读取下载地址
.setFilePath(PathUtils.getExternalDownloadsPath() + "/ygj/" + EncryptUtils.encryptMD5ToString("com.jiaoguanyi.store") + ".apk", true)
.setFilePath(PathUtils.getExternalDownloadsPath() + "/ygj/" + EncryptUtils.encryptMD5ToString(url) + ".apk", true)
.setExtendField(packageObj.toJSONString())
.create(); //启动下载}
@@ -862,46 +905,7 @@ public class MyJPushReceiver extends BroadcastReceiver {
}
}
@Override
public void onReceive(Context context, Intent intent) {
mContext = context;
Bundle bundle = intent.getExtras();
if (JPushInterface.ACTION_REGISTRATION_ID.equals(intent.getAction())) {
String regId = bundle.getString(JPushInterface.EXTRA_REGISTRATION_ID);
Log.e(TAG, "[MyReceiver] 接收Registration Id : " + regId);
//send the Registration Id to your server...
} else if (JPushInterface.ACTION_MESSAGE_RECEIVED.equals(intent.getAction())) {
// ToastTool.show("[MyReceiver] 接收到推送下来的自定义消息: " + bundle.getString(JPushInterface.EXTRA_MESSAGE)
// + "---" + bundle.getString(JPushInterface.EXTRA_TITLE) + "---" + bundle.getString(JPushInterface.EXTRA_CONTENT_TYPE)
// + "---" + bundle.getString(JPushInterface.EXTRA_EXTRA) + "----" + bundle.getString("package_name"));
// Log.e(TAG, "[MyReceiver] 接收到推送下来的自定义消息: " + bundle.getString(JPushInterface.EXTRA_MESSAGE)
// + "---" + bundle.getString(JPushInterface.EXTRA_TITLE) + "---" + bundle.getString(JPushInterface.EXTRA_CONTENT_TYPE)
// + "---" + bundle.getString(JPushInterface.EXTRA_EXTRA) + "----" + bundle.getString("package_name"));
processCustomMessage(context, bundle);//屏蔽推送
} else if (JPushInterface.ACTION_NOTIFICATION_RECEIVED.equals(intent.getAction())) {
Log.e(TAG, "[MyReceiver] 接收到推送下来的通知" + bundle.getString(JPushInterface.EXTRA_EXTRA));
// doDownloadAndInstall(bundle.getString(JPushInterface.EXTRA_EXTRA));
// LogUtils.e(getBatteryLevel()+"-0-iweroiwerewefeerer-----------");
int notifactionId = bundle.getInt(JPushInterface.EXTRA_NOTIFICATION_ID);
Log.e(TAG, "[MyReceiver] 接收到推送下来的通知的ID: " + notifactionId);
} else if (JPushInterface.ACTION_NOTIFICATION_OPENED.equals(intent.getAction())) {
Log.e(TAG, "[MyReceiver] 用户点击打开了通知");
} else if (JPushInterface.ACTION_RICHPUSH_CALLBACK.equals(intent.getAction())) {
Log.e(TAG, "[MyReceiver] 用户收到到RICH PUSH CALLBACK: " + bundle.getString(JPushInterface.EXTRA_EXTRA));
//在这里根据 JPushInterface.EXTRA_EXTRA 的内容处理代码比如打开新的Activity 打开一个网页等..
} else if (JPushInterface.ACTION_CONNECTION_CHANGE.equals(intent.getAction())) {
boolean connected = intent.getBooleanExtra(JPushInterface.EXTRA_CONNECTION_CHANGE, false);
Log.e(TAG, "[MyReceiver]" + intent.getAction() + " connected state change to " + connected);
} else {
Log.e(TAG, "[MyReceiver] Unhandled intent - " + intent.getAction());
}
}
public void settingLock(String s) {
if (TextUtils.isEmpty(s)) {