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:
Max Lv
2016-01-30 14:01:46 +08:00
parent 2840a75c92
commit 187cb28d15
@@ -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() {