From 56de231c4f5365983c4e72094f96714b6245ded0 Mon Sep 17 00:00:00 2001 From: Mygod Date: Fri, 17 Jun 2016 17:38:27 +0800 Subject: [PATCH] Refine #530 --- .../scala/com/github/shadowsocks/ServiceBoundContext.scala | 1 - .../scala/com/github/shadowsocks/ShadowsocksNotification.scala | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/scala/com/github/shadowsocks/ServiceBoundContext.scala b/src/main/scala/com/github/shadowsocks/ServiceBoundContext.scala index c2df8d68..40ec6f3e 100644 --- a/src/main/scala/com/github/shadowsocks/ServiceBoundContext.scala +++ b/src/main/scala/com/github/shadowsocks/ServiceBoundContext.scala @@ -62,7 +62,6 @@ trait ServiceBoundContext extends Context with IBinder.DeathRecipient { connection = new ShadowsocksServiceConnection() bindService(intent, connection, Context.BIND_AUTO_CREATE) - startService(intent) } } diff --git a/src/main/scala/com/github/shadowsocks/ShadowsocksNotification.scala b/src/main/scala/com/github/shadowsocks/ShadowsocksNotification.scala index 73b61938..6691ffd8 100644 --- a/src/main/scala/com/github/shadowsocks/ShadowsocksNotification.scala +++ b/src/main/scala/com/github/shadowsocks/ShadowsocksNotification.scala @@ -83,7 +83,9 @@ class ShadowsocksNotification(private val service: BaseService, profileName: Str show() } else if (forceShow) show() + private lazy val intent = new Intent(service, service.getClass) def show() = { + service.startService(intent) service.startForeground(1, builder.build) } @@ -94,6 +96,7 @@ class ShadowsocksNotification(private val service: BaseService, profileName: Str } unregisterCallback service.stopForeground(true) + service.stopService(intent) nm.cancel(1) } }