From 0281b9c5c53582cfb566524f631f3ca346b77124 Mon Sep 17 00:00:00 2001 From: vadym Date: Tue, 7 Jul 2020 01:31:32 -0700 Subject: [PATCH] 1. open MainActivity after Notification click, task #12 --- app/src/main/AndroidManifest.xml | 2 ++ .../github/chronosx88/yggdrasil/YggdrasilTunService.kt | 10 ++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index ee57592..18c1ee0 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -16,11 +16,13 @@ tools:ignore="GoogleAppIndexingWarning"> diff --git a/app/src/main/java/io/github/chronosx88/yggdrasil/YggdrasilTunService.kt b/app/src/main/java/io/github/chronosx88/yggdrasil/YggdrasilTunService.kt index 96e95ad..b0e593a 100644 --- a/app/src/main/java/io/github/chronosx88/yggdrasil/YggdrasilTunService.kt +++ b/app/src/main/java/io/github/chronosx88/yggdrasil/YggdrasilTunService.kt @@ -1,9 +1,6 @@ package io.github.chronosx88.yggdrasil -import android.app.Notification -import android.app.NotificationChannel -import android.app.NotificationManager -import android.app.PendingIntent +import android.app.* import android.content.Context import android.content.Intent import android.net.ConnectivityManager @@ -292,8 +289,13 @@ class YggdrasilTunService : VpnService() { // https://developer.android.com/reference/android/support/v4/app/NotificationCompat.Builder.html#NotificationCompat.Builder(android.content.Context) "" } + var intent = Intent(this, MainActivity::class.java) + var stackBuilder = TaskStackBuilder.create(this) + stackBuilder.addNextIntentWithParentStack(intent) + var pi = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT) val b = NotificationCompat.Builder(this, channelId) b.setOngoing(true) + .setContentIntent(pi) .setContentTitle(getString(R.string.app_name)) .setContentText(text) .setSmallIcon(R.mipmap.ic_launcher)