@@ -178,6 +178,7 @@ private void startForegroundNew() {
178178 .setContentTitle ("Atjeews server" )
179179 .setPriority (NotificationManager .IMPORTANCE_MIN )
180180 .setCategory (Notification .CATEGORY_SERVICE )
181+ //.addAction(R.drawable.button_onoff_indicator_on, getString(R.string.srv_ctrl), startStopIntent);
181182 .build ();
182183 startForeground (2 , notification );
183184 }
@@ -196,6 +197,8 @@ private void startServ() {
196197 public void run () {
197198 status = ST_RUN ;
198199 int code = 0 ;
200+ if (logStream == null )
201+ initLogging ();
199202 if (wifiLock == null ) {
200203 WifiManager wifiManager = (WifiManager ) getApplicationContext ().getSystemService (Context .WIFI_SERVICE );
201204 wifiLock = wifiManager .createWifiLock (SERVICE_NAME );
@@ -212,6 +215,8 @@ public void run() {
212215 if (wifiLock != null && wifiLock .isHeld ())
213216 wifiLock .release ();
214217 status = code == 0 ? ST_STOP : ST_ERR ;
218+ logStream .close ();
219+ logStream = null ;
215220 // TODO find out how notify client
216221 }
217222 }
@@ -261,8 +266,10 @@ protected void initServ() {
261266 }
262267
263268 @ SuppressLint ("NewApi" ) protected void initLogging () {
264- if (logStream != null )
265- return ;
269+ if (logStream != null ) {
270+ logStream .close ();
271+ logStream = null ;
272+ }
266273 File logDir = new File (protectedFS ? getExternalCacheDir ()
267274 : Environment .getExternalStorageDirectory (), LOGDIR );
268275 if (Main .DEBUG )
@@ -278,8 +285,11 @@ protected void initServ() {
278285 }
279286 if (logStream == null )
280287 logStream = System .out ;
281- else
288+ else {
282289 System .setErr (logStream );
290+ System .setOut (logStream );
291+ }
292+
283293 }
284294
285295 protected void initDeployDirectory () {
0 commit comments