导航菜单

页面标题

页面副标题

新暖心缘 v8.1.1 - MyReceiver.java 源代码

正在查看: 新暖心缘 v8.1.1 应用的 MyReceiver.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package com.luanxingyuan.app.jpush;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import cn.jpush.android.api.JPushInterface;
import com.luanxingyuan.app.activity.SystemMessageActivity;
import com.luanxingyuan.app.base.AppManager;
import com.luanxingyuan.app.socket.ConnectHelper;
import com.luanxingyuan.app.util.LogUtil;
import java.util.Iterator;
import org.json.JSONException;
import org.json.JSONObject;

public class MyReceiver extends BroadcastReceiver {
    private void a(Bundle bundle, Context context) {
        String string = bundle.getString(JPushInterface.EXTRA_MESSAGE);
        LogUtil.i("接收到推送下来的自定义消息: " + string);
        Iterator<String> it = bundle.keySet().iterator();
        while (it.hasNext()) {
            if (it.next().equals(JPushInterface.EXTRA_EXTRA)) {
                String string2 = bundle.getString(JPushInterface.EXTRA_EXTRA);
                if (!TextUtils.isEmpty(string2)) {
                    try {
                        JSONObject jSONObject = new JSONObject(string2);
                        Iterator<String> keys = jSONObject.keys();
                        while (keys.hasNext()) {
                            if (keys.next().equals("noticeType") && jSONObject.getInt("noticeType") == 1) {
                                Intent intent = new Intent("com.newslapp.live.socket");
                                intent.putExtra("message", "{\"mid\":30006}");
                                context.sendBroadcast(intent);
                                AppManager.f().c(string, true);
                            }
                        }
                    } catch (JSONException e8) {
                        e8.printStackTrace();
                    }
                }
            }
        }
    }

    private static String b(Bundle bundle) {
        StringBuilder sb = new StringBuilder();
        for (String str : bundle.keySet()) {
            if (str.equals(JPushInterface.EXTRA_NOTIFICATION_ID)) {
                sb.append("\nkey:" + str + ", value:" + bundle.getInt(str));
            } else if (str.equals(JPushInterface.EXTRA_CONNECTION_CHANGE)) {
                sb.append("\nkey:" + str + ", value:" + bundle.getBoolean(str));
            } else if (!str.equals(JPushInterface.EXTRA_EXTRA)) {
                sb.append("\nkey:" + str + ", value:" + bundle.get(str));
            } else if (TextUtils.isEmpty(bundle.getString(JPushInterface.EXTRA_EXTRA))) {
                LogUtil.i("This message has no Extra data");
            } else {
                try {
                    JSONObject jSONObject = new JSONObject(bundle.getString(JPushInterface.EXTRA_EXTRA));
                    Iterator<String> keys = jSONObject.keys();
                    while (keys.hasNext()) {
                        String next = keys.next();
                        sb.append("\nkey:" + str + ", value: [" + next + " - " + jSONObject.optString(next) + "]");
                    }
                } catch (JSONException unused) {
                    LogUtil.i("Get message extra JSON error!");
                }
            }
        }
        return sb.toString();
    }

    @Override
    public void onReceive(Context context, Intent intent) {
        try {
            Bundle extras = intent.getExtras();
            if (extras != null) {
                LogUtil.i("[MyReceiver] onReceive - " + intent.getAction() + ", extras: " + b(extras));
                if (JPushInterface.ACTION_MESSAGE_RECEIVED.equals(intent.getAction())) {
                    a(extras, context);
                } else if (JPushInterface.ACTION_NOTIFICATION_OPENED.equals(intent.getAction())) {
                    LogUtil.i("用户点击打开了通知");
                    Intent intent2 = new Intent(context, (Class<?>) SystemMessageActivity.class);
                    intent2.putExtras(extras);
                    intent2.setFlags(335544320);
                    context.startActivity(intent2);
                } else if (JPushInterface.ACTION_RICHPUSH_CALLBACK.equals(intent.getAction())) {
                    LogUtil.i("[MyReceiver] 用户收到到RICH PUSH CALLBACK: " + extras.getString(JPushInterface.EXTRA_EXTRA));
                } else if (JPushInterface.ACTION_CONNECTION_CHANGE.equals(intent.getAction())) {
                    LogUtil.i("[MyReceiver]" + intent.getAction() + " connected state change to " + intent.getBooleanExtra(JPushInterface.EXTRA_CONNECTION_CHANGE, false));
                } else {
                    LogUtil.i("[MyReceiver] Unhandled intent - " + intent.getAction());
                }
            }
        } catch (Exception e8) {
            e8.printStackTrace();
        }
        ConnectHelper.get().checkConnect();
    }
}