android: how to call activity by clicking foreground service notification

拈花ヽ惹草 提交于 2019-12-06 13:02:37

try this solution

Intent notificationIntent = new Intent(this, MainGate.class);
PendingIntent pendingIntent=PendingIntent.getActivity(this, 0,
        notificationIntent, Intent.FLAG_ACTIVITY_NEW_TASK);

Notification notification=new NotificationCompat.Builder(this)
                            .setSmallIcon(R.drawable.ic_launcher)
                            .setContentText(getString(R.string.isRecording))
                            .setContentIntent(pendingIntent).build();

startForeground(NOTIFICATION_ID, notification);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!