【发布时间】:2015-03-08 10:36:49
【问题描述】:
我有一个前台服务,我想让通知在用户点击通知时打开 MainActivity。
自定义Service类中创建Notification的方法是:
public void setForeground(final int notificationID, final int notificationIconID,
final String notificationTickerText,
final String notificationTitle, final String notificationText){
Notification notification = new Notification(notificationIconID, notificationTickerText,
System.currentTimeMillis());
notification.setLatestEventInfo(this, notificationTitle,
notificationText, PendingIntent.getActivity(this, 0, new Intent(this, this.getClass()), 0));
startForeground(notificationID, notification);
}
如何修改它以包含打开(如果 MainActivity 当前已打开)或在通知点击功能上启动 MainActivity?
【问题讨论】:
标签: java android android-activity android-service