在我的应用程序中,我有一个前台服务,在按下时会启动一个具有以下PendingIntent
的Activity @Override
public int onStartCommand(Intent intent, int flags, int startId) {
...
startForeground(FOREGROUND_SERVICE_ID, getNotification());
}
private Notification getNotification(){
Intent notificationIntent = new Intent(this, CallActivity.class);
notificationIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(this, FOREGROUND_SERVICE_ID, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
...
return notification;
}
活动开始并且一切正常,但是,当我调用finish()时它不会关闭Activity,尽管它正在运行finish();声明,我确保使用调试器。