Fix an issue of NAT mode
If call notify() after startForeground() on the same notification id, the service becomes not that "foreground" and would be killed by system if the activity is removed from the recent list.
This commit is contained in:
@@ -30,7 +30,6 @@ class ShadowsocksNotification(private val service: BaseService, profileName: Str
|
||||
}
|
||||
private var lockReceiver: BroadcastReceiver = _
|
||||
private var callbackRegistered: Boolean = _
|
||||
private var started: Boolean = _
|
||||
|
||||
private val builder = new NotificationCompat.Builder(service)
|
||||
.setWhen(0)
|
||||
@@ -77,9 +76,8 @@ class ShadowsocksNotification(private val service: BaseService, profileName: Str
|
||||
show()
|
||||
} else if (forceShow) show()
|
||||
|
||||
def show() = if (started) nm.notify(1, builder.build) else {
|
||||
def show() = {
|
||||
service.startForeground(1, builder.build)
|
||||
started = true
|
||||
}
|
||||
|
||||
def destroy() {
|
||||
|
||||
Reference in New Issue
Block a user