当我的广播接收器被触发时,它将发出通知,指导用户进行应用程序中构建的聊天活动。
问题是当用户在应用程序内部执行操作时。 (它的主要目的不是聊天)
我希望它回到他触发通知的活动。这可能是应用程序内的任何地方。
构建通知:
notificationIntent = new Intent(mContext, BerichtenActivity.class);
Toast.makeText(context, verzender + ": " + inhoud, Toast.LENGTH_LONG).show();
Notification notification = NotificationUtils.handleNotification(mContext, notificationIntent, verzender, inhoud, R.drawable.ic_stat_chat);
NotificationManager notificationManager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(notificationId, notification);
public static Notification handleNotification(Context context, Intent resultIntent, String titel, String body, int smallIcon){
PendingIntent resultPendingIntent = PendingIntent.getActivity(context, 0, resultIntent, 0);
Uri uri= RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context)
.setAutoCancel(true)
.setContentText(body)
.setContentTitle(titel)
.setContentIntent(resultPendingIntent)
.setSound(uri)
.setLargeIcon(BitmapFactory.decodeResource(
context.getResources(), R.mipmap.ic_launcher))
.setSmallIcon(smallIcon);
return notificationBuilder.build();
}