From 1e0f640a2068d2db5bae2c36a9477fb2042282e1 Mon Sep 17 00:00:00 2001 From: Nathan Freitas Date: Mon, 24 Nov 2014 23:12:53 -0500 Subject: [PATCH] adding dummyactivity to stop task/broadcast from killing foreground service --- AndroidManifest.xml | 24 +++++++++++++++---- .../android/service/DummyActivity.java | 15 ++++++++++++ .../android/service/TorService.java | 6 ++++- 3 files changed, 40 insertions(+), 5 deletions(-) create mode 100644 src/org/torproject/android/service/DummyActivity.java diff --git a/AndroidManifest.xml b/AndroidManifest.xml index de175f96..223475fd 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -2,11 +2,11 @@ - + @@ -24,10 +24,13 @@ android:allowClearUserData="true" android:persistent="true" android:stopWithTask="false" + > - @@ -73,7 +76,20 @@ - + + + diff --git a/src/org/torproject/android/service/DummyActivity.java b/src/org/torproject/android/service/DummyActivity.java new file mode 100644 index 00000000..5400ba4f --- /dev/null +++ b/src/org/torproject/android/service/DummyActivity.java @@ -0,0 +1,15 @@ +package org.torproject.android.service; + +import android.app.Activity; +import android.os.Bundle; + +/* + * To combat background service being stopped/swiped + */ +public class DummyActivity extends Activity { + @Override + public void onCreate( Bundle icicle ) { + super.onCreate( icicle ); + finish(); + } +} \ No newline at end of file diff --git a/src/org/torproject/android/service/TorService.java b/src/org/torproject/android/service/TorService.java index 6323d83b..71b2ed78 100644 --- a/src/org/torproject/android/service/TorService.java +++ b/src/org/torproject/android/service/TorService.java @@ -412,7 +412,11 @@ public class TorService extends Service implements TorServiceConstants, TorConst @Override public void onTaskRemoved(Intent rootIntent) { - logNotice("Orbot was swiped away... background service will keep running"); + //logNotice("Orbot was swiped away... background service will keep running"); + + Intent intent = new Intent( this, DummyActivity.class ); + intent.addFlags( Intent.FLAG_ACTIVITY_NEW_TASK ); + startActivity( intent ); } @Override