Android 通知 点击通知 跳转到对应页面

Bitmap btm= BitmapFactory.decodeResource(getResources(), R.drawable.ic_menu_compose);

NotificationCompat.Builder mBuilder=newNotificationCompat.Builder(getApplication()).setSmallIcon(R.mipmap.ic_launcher)

.setContentTitle("消息").setContentText("新消息");

mBuilder.setTicker("新的消息");

//mBuilder.setNumber(12);

mBuilder.setLargeIcon(btm);

mBuilder.setAutoCancel(true);

mBuilder.setPriority(Notification.PRIORITY_MAX);

mBuilder.setDefaults(Notification.DEFAULT_ALL);

mBuilder.setOnlyAlertOnce(true);

//构建一个intent

Intent resultIntent=newIntent(getApplicationContext(), PushNewsActivity.class);

resultIntent.putExtra("content",content);

resultIntent.putExtra("id",idChar);

resultIntent.putExtra("title",title);

PendingIntent resultPI=PendingIntent.getActivity(getApplication(),requestCode,resultIntent,PendingIntent.FLAG_CANCEL_CURRENT);

mBuilder.setContentIntent(resultPI);

NotificationManager mNotif= (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

mNotif.notify(requestCode,mBuilder.build());

你可能感兴趣的:(Android 通知 点击通知 跳转到对应页面)