【发布时间】:2014-06-22 10:05:53
【问题描述】:
我在我的应用程序中实现了一些通知。似乎每次我点击通知时都会启动一个新的意图。目标是将应用程序置于前台,因为它仍处于后台(因此不会被杀死)。
我怎样才能做到这一点?
mNotificationManager = (NotificationManager)
this.getSystemService(Context.NOTIFICATION_SERVICE);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
new Intent(this, ChatActivity.class), 0);
long[] vibration = new long[]{100, 250};
NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.icon)
.setAutoCancel(true)
.setTicker(msg)
.setLights(Color.WHITE, 300, 600)
.setSound(Uri.parse("android.resource://" + getApplicationContext().getPackageName() + "/" + R.raw.new_msg))
.setVibrate(vibration)
.setContentText(msg);
mBuilder.setContentIntent(contentIntent);
mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build());
【问题讨论】:
标签: java android android-intent notifications