【发布时间】:2017-03-23 13:05:38
【问题描述】:
我启动了一个显示通知的前台服务。如果我的活动被隐藏,我希望通过单击通知开始。 在 onStartCommand 中调用的函数会这样做:
startForeground(noti_id, mNoti);
通知出现并且有效,但它不会重新激活我的 MainActivity:
notiIntent = new Intent(this, MainGate.class);
notiPendingIntent = PendingIntent.getActivity(this, 0, notiIntent, PendingIntent.FLAG_UPDATE_CURRENT);
MainGate.class 是启动前台服务的活动。当我点击通知时它应该会出现。
编辑:
实际上,当通知构建在 man 活动 (MainGate.class) 中时,它就起作用了。当通知内置在不是前台服务的服务中时,它就起作用了。现在我不得不实现前台服务并且它停止工作了。
【问题讨论】:
标签: android notifications foreground