点击通知收不到ACTION_NOTIFICATION_OPENED广播
jcenter集成,
public class JPushReceiver extends BroadcastReceiver {
public static String RegistrationID;
@Override
public void onReceive(Context context, Intent intent) {
Bundle bundle = intent.getExtras();
if (LogUtil.DEBUG) {
LogUtil.e(this, "[MyReceiver] onReceive - " + intent.getAction() + ", extras: " + printBundle(bundle));
}
if (bundle == null) {
return;
}
RegistrationID = JPushInterface.getRegistrationID(context);
if (JPushInterface.ACTION_REGISTRATION_ID.equals(intent.getAction())) {
String regId = bundle.getString(JPushInterface.EXTRA_REGISTRATION_ID);
sendRegistrationID(regId, context);
} else if (JPushInterface.ACTION_MESSAGE_RECEIVED.equals(intent.getAction())) {
} else if (JPushInterface.ACTION_NOTIFICATION_RECEIVED.equals(intent.getAction())) {
int notifactionId = bundle.getInt(JPushInterface.EXTRA_NOTIFICATION_ID);
} else if (JPushInterface.ACTION_NOTIFICATION_OPENED.equals(intent.getAction())) {
if (bundle != null) {
try {
PushEntity en = new PushEntity();
en.title = bundle.getString(JPushInterface.EXTRA_NOTIFICATION_TITLE);
en.description = bundle.getString(JPushInterface.EXTRA_ALERT);
String extra = bundle.getString(JPushInterface.EXTRA_EXTRA);
if (!TextUtils.isEmpty(extra)) {
JSONObject json = new JSONObject(extra);
en.type = Integer.parseInt(json.getString("type"));
en.id = json.getString("id");
switch (en.type) {
case 1:
if (json.has("special_id")) {
en.param1 = json.getString("special_id");
}
if (json.has("special_type")) {
en.param2 = json.getString("special_type");
}
break;
case 3:
if (json.has("url")) {
en.param1 = json.getString("url");
}
break;
case 6:
case 8:
case 9:
break;
case 10:
en.param1 = extra;
break;
}
Bundle b = new Bundle();
b.putSerializable(_BaseActivity._EXTRA_Serializable, en);
Intent in = new Intent(context.getApplicationContext(), MainActivity.class);
in.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
in.putExtras(b);
context.getApplicationContext().startActivity(in);
}
} catch (Exception e) {
if (LogUtil.DEBUG) {
LogUtil.e(e);
}
}
}
} else if (JPushInterface.ACTION_RICHPUSH_CALLBACK.equals(intent.getAction())) {
} else if (JPushInterface.ACTION_CONNECTION_CHANGE.equals(intent.getAction())) {
} else {
}
}
打印log
发现通知消息接收到了,也显示在通知栏了,但是点击通知栏没有收到ACTION_NOTIFICATION_OPENED事件