注册

点击了广播,却无法跳转

代码已经执行了,但是点击广播页面不跳转


234sdf.png


 
已邀请:
您好,感觉像是没有设置完整,下面是我写的一个通知类的点击跳转的,您参考一下吧

C54434A6-C356-4FEF-9D5C-4DC228A1E0F8.png


 
 /**
* send it to notification bar
* This can be override by subclass to provide customer implementation
* @param message
*/
protected void sendNotification(EMMessage message, boolean isForeground, boolean numIncrease) {
String username = message.getFrom();
try {
String notifyText = username + " ";
switch (message.getType()) {
case TXT:
notifyText += msgs[0];
break;
case IMAGE:
notifyText += msgs[1];
break;
case VOICE:

notifyText += msgs[2];
break;
case LOCATION:
notifyText += msgs[3];
break;
case VIDEO:
notifyText += msgs[4];
break;
case FILE:
notifyText += msgs[5];
break;
}

PackageManager packageManager = appContext.getPackageManager();
String appname = (String) packageManager.getApplicationLabel(appContext.getApplicationInfo());

// notification title
String contentTitle = appname;
if (notificationInfoProvider != null) {
String customNotifyText = notificationInfoProvider.getDisplayedText(message);
String customCotentTitle = notificationInfoProvider.getTitle(message);
if (customNotifyText != null) {
notifyText = customNotifyText;
}

if (customCotentTitle != null) {
contentTitle = customCotentTitle;
}
}

// create and send notificaiton
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(appContext)
.setSmallIcon(appContext.getApplicationInfo().icon)
.setWhen(System.currentTimeMillis())
.setAutoCancel(true);

Intent msgIntent = appContext.getPackageManager().getLaunchIntentForPackage(packageName);
if (notificationInfoProvider != null) {
msgIntent = notificationInfoProvider.getLaunchIntent(message);
}

PendingIntent pendingIntent = PendingIntent.getActivity(appContext, notifyID, msgIntent, PendingIntent.FLAG_UPDATE_CURRENT);

if (numIncrease) {
// prepare latest event info section
if (!isForeground) {
notificationNum++;
fromUsers.add(message.getFrom());
}
}

int fromUsersNum = fromUsers.size();
String summaryBody = msgs[6].replaceFirst("%1", Integer.toString(fromUsersNum)).replaceFirst("%2", Integer.toString(notificationNum));

if (notificationInfoProvider != null) {
// lastest text
String customSummaryBody = notificationInfoProvider.getLatestText(message, fromUsersNum, notificationNum);
if (customSummaryBody != null) {
summaryBody = customSummaryBody;
}

// small icon
int smallIcon = notificationInfoProvider.getSmallIcon(message);
if (smallIcon != 0) {
mBuilder.setSmallIcon(smallIcon);
}
}

mBuilder.setContentTitle(contentTitle);
mBuilder.setTicker(notifyText);
mBuilder.setContentText(summaryBody);
mBuilder.setContentIntent(pendingIntent);
// mBuilder.setNumber(notificationNum);
Notification notification = mBuilder.build();

if (isForeground) {
notificationManager.notify(foregroundNotifyID, notification);
notificationManager.cancel(foregroundNotifyID);
} else {
notificationManager.notify(notifyID, notification);
}

} catch (Exception e) {
e.printStackTrace();
}
}

要回复问题请先登录注册