1. open MainActivity after Notification click, task #12

This commit is contained in:
vadym 2020-07-07 01:31:32 -07:00
parent 507602cd2b
commit 0281b9c5c5
2 changed files with 8 additions and 4 deletions

View File

@ -16,11 +16,13 @@
tools:ignore="GoogleAppIndexingWarning"> tools:ignore="GoogleAppIndexingWarning">
<activity <activity
android:name=".PeerListActivity" android:name=".PeerListActivity"
android:parentActivityName=".MainActivity"
android:label="@string/title_activity_peer_list" android:label="@string/title_activity_peer_list"
android:theme="@style/AppTheme.NoActionBar" android:theme="@style/AppTheme.NoActionBar"
android:screenOrientation="portrait"/> android:screenOrientation="portrait"/>
<activity <activity
android:name=".DNSListActivity" android:name=".DNSListActivity"
android:parentActivityName=".MainActivity"
android:label="@string/title_activity_dns_list" android:label="@string/title_activity_dns_list"
android:theme="@style/AppTheme.NoActionBar" android:theme="@style/AppTheme.NoActionBar"
android:screenOrientation="portrait"/> android:screenOrientation="portrait"/>

View File

@ -1,9 +1,6 @@
package io.github.chronosx88.yggdrasil package io.github.chronosx88.yggdrasil
import android.app.Notification import android.app.*
import android.app.NotificationChannel
import android.app.NotificationManager
import android.app.PendingIntent
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import android.net.ConnectivityManager 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) // 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) val b = NotificationCompat.Builder(this, channelId)
b.setOngoing(true) b.setOngoing(true)
.setContentIntent(pi)
.setContentTitle(getString(R.string.app_name)) .setContentTitle(getString(R.string.app_name))
.setContentText(text) .setContentText(text)
.setSmallIcon(R.mipmap.ic_launcher) .setSmallIcon(R.mipmap.ic_launcher)