导航菜单

页面标题

页面副标题

爱心e站 v1.0.0 - GeTuiIntentSeivice.java 源代码

正在查看: 爱心e站 v1.0.0 应用的 GeTuiIntentSeivice.java JAVA 源代码文件

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


package com.newheyd.JZKFcanjiren.service;

import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.graphics.BitmapFactory;
import android.support.v7.app.NotificationCompat;
import android.util.Log;
import com.igexin.sdk.GTIntentService;
import com.igexin.sdk.PushConsts;
import com.igexin.sdk.PushManager;
import com.igexin.sdk.message.GTCmdMessage;
import com.igexin.sdk.message.GTNotificationMessage;
import com.igexin.sdk.message.GTTransmitMessage;
import com.newheyd.JZKFcanjiren.Activity.HomeFragActivity;
import com.newheyd.JZKFcanjiren.Bean.GTBean;
import com.newheyd.JZKFcanjiren.Bean.MessageEvent;
import com.newheyd.JZKFcanjiren.R;
import com.newheyd.JZKFcanjiren.Utils.NewLogUtil;
import com.newheyd.JZKFcanjiren.Utils.SharedPreferencedUtils;
import com.newheyd.JZKFcanjiren.config.NewHYConfig;
import org.greenrobot.eventbus.EventBus;
import org.json.JSONException;
import org.json.JSONObject;

public class GeTuiIntentSeivice extends GTIntentService {
    private static final String TAG = "GetuiSdkDemo";
    private static int cnt;
    private NotificationManager notificationManager = null;

    @Override
    public void onReceiveServicePid(Context context, int pid) {
        Log.d(TAG, "onReceiveServicePid -> " + pid);
    }

    @Override
    public void onReceiveMessageData(Context context, GTTransmitMessage msg) {
        GTBean gtBean;
        String appid = msg.getAppid();
        String taskid = msg.getTaskId();
        String messageid = msg.getMessageId();
        byte[] payload = msg.getPayload();
        String pkg = msg.getPkgName();
        String cid = msg.getClientId();
        boolean result = PushManager.getInstance().sendFeedbackMessage(context, taskid, messageid, PushConsts.MIN_FEEDBACK_ACTION);
        Log.d(TAG, "call sendFeedbackMessage = " + (result ? "success" : "failed"));
        Log.d(TAG, "onReceiveMessageData -> appid = " + appid + "\ntaskid = " + taskid + "\nmessageid = " + messageid + "\npkg = " + pkg + "\ncid = " + cid);
        if (payload == null) {
            NewLogUtil.debug("receiver payload = null");
        }
        String data = new String(payload);
        NewLogUtil.debug("receiver payload = " + data);
        if (data != null) {
            try {
                JSONObject msgJson = new JSONObject(data);
                gtBean = new GTBean(msgJson);
                switch (gtBean.getType()) {
                    case "0":
                        MessageEvent msgEvent = new MessageEvent(gtBean.getContent(), NewHYConfig.OTHER_PHONE_LOGN);
                        EventBus.getDefault().post(msgEvent);
                        break;
                    default:
                        showNotification(gtBean);
                        break;
                }
            } catch (JSONException e) {
            }
        }
    }

    @Override
    public void onReceiveClientId(Context context, String clientid) {
        Log.e(TAG, "onReceiveClientId -> clientid = " + clientid);
        SharedPreferencedUtils.getInstance(context).putString(PushConsts.KEY_CLIENT_ID, clientid);
        MessageEvent event = new MessageEvent("个推初始化成功", 2);
        EventBus.getDefault().post(event);
    }

    @Override
    public void onReceiveOnlineState(Context context, boolean online) {
        Log.d(TAG, "onReceiveOnlineState -> " + (online ? "online" : "offline"));
    }

    @Override
    public void onReceiveCommandResult(Context context, GTCmdMessage cmdMessage) {
        Log.d(TAG, "onReceiveCommandResult -> " + cmdMessage);
    }

    @Override
    public void onNotificationMessageArrived(Context context, GTNotificationMessage message) {
        Log.d(TAG, "onNotificationMessageArrived -> appid = " + message.getAppid() + "\ntaskid = " + message.getTaskId() + "\nmessageid = " + message.getMessageId() + "\npkg = " + message.getPkgName() + "\ncid = " + message.getClientId() + "\ntitle = " + message.getTitle() + "\ncontent = " + message.getContent());
    }

    @Override
    public void onNotificationMessageClicked(Context context, GTNotificationMessage message) {
        Log.d(TAG, "onNotificationMessageClicked -> appid = " + message.getAppid() + "\ntaskid = " + message.getTaskId() + "\nmessageid = " + message.getMessageId() + "\npkg = " + message.getPkgName() + "\ncid = " + message.getClientId() + "\ntitle = " + message.getTitle() + "\ncontent = " + message.getContent());
    }

    private void showNotification(GTBean gtBean) {
        String msg_content = gtBean.getContent();
        gtBean.getType();
        gtBean.getRelationId();
        Intent intent = new Intent(getApplicationContext(), (Class<?>) HomeFragActivity.class);
        intent.setFlags(268435456);
        intent.setFlags(8388608);
        intent.setFlags(1073741824);
        intent.setFlags(536870912);
        intent.setFlags(67108864);
        PendingIntent contentIntent = PendingIntent.getActivity(getApplicationContext(), 0, intent, 134217728);
        if (this.notificationManager == null) {
            this.notificationManager = (NotificationManager) getApplicationContext().getSystemService("notification");
        }
        NotificationCompat.Builder builder = new NotificationCompat.Builder(getApplicationContext());
        builder.setSmallIcon(R.mipmap.ic_launcher);
        builder.setLargeIcon(BitmapFactory.decodeResource(getApplicationContext().getResources(), R.mipmap.ic_launcher));
        builder.setTicker(msg_content);
        builder.setContentTitle(getResources().getString(2131296314));
        builder.setContentText(msg_content);
        builder.setContentIntent(contentIntent);
        builder.setWhen(System.currentTimeMillis());
        builder.setAutoCancel(true);
        builder.setDefaults(5);
        int index = SharedPreferencedUtils.getInstance(getApplicationContext()).getInt("index", 0);
        this.notificationManager.notify(index, builder.build());
        int i = index + 1;
        SharedPreferencedUtils.getInstance(getApplicationContext()).getInt("index", index);
    }
}