我启动了一个前台服务,它会显示一个通知。如果我的活动被隐藏了,我希望通过点击通知来启动它。 在onStartCommand中调用的一个函数可以实现这个功能:
startForeground(noti_id, mNoti);
通知出现并且工作了,但它没有重新激活我的MainActivity。
notiIntent = new Intent(this, MainGate.class);
notiPendingIntent = PendingIntent.getActivity(this, 0, notiIntent, PendingIntent.FLAG_UPDATE_CURRENT);
MainGate.class是启动前台服务的活动。当我点击通知时,它应该出现。
编辑:
实际上,当通知在主要活动(MainGate.class)中构建时,它可以工作。并且当通知在不是前台服务的服务中构建时,它也可以工作。现在我必须实现前台服务,但它停止工作了。