diff --git a/FMRecord/AndroidManifest.xml b/FMRecord/AndroidManifest.xml index 96c0177f2c163fd783f472d24446ba80ce5f80b5..c1df6469cb74c444ba73d565ea3be649f5958d3d 100644 --- a/FMRecord/AndroidManifest.xml +++ b/FMRecord/AndroidManifest.xml @@ -34,6 +34,7 @@ <uses-permission android:name="android.permission.CAPTURE_AUDIO_OUTPUT" /> <uses-permission android:name="android.permission.INTERACT_ACROSS_USERS_FULL"/> <uses-permission android:name="android.permission.INTERACT_ACROSS_USERS" /> + <uses-permission android:name="android.permission.REAL_GET_TASKS" /> <application> diff --git a/fmapp2/src/com/caf/fmradio/FMRadio.java b/fmapp2/src/com/caf/fmradio/FMRadio.java index ff488472e7b33f42ff1c23dd7f07ee7b3365fe28..c36488595cacea536047d4f9bad8f41c2c74dd28 100644 --- a/fmapp2/src/com/caf/fmradio/FMRadio.java +++ b/fmapp2/src/com/caf/fmradio/FMRadio.java @@ -2976,14 +2976,21 @@ public class FMRadio extends Activity public void unbindFromService(Context context) { ServiceBinder sb = (ServiceBinder) sConnectionMap.remove(context); + boolean isFmOn = isFmOn(); Log.e(LOGTAG, "unbindFromService: Context"); if (sb == null) { Log.e(LOGTAG, "Trying to unbind for unknown Context"); return; } context.unbindService(sb); - Log.e(LOGTAG, "stop FM radio service"); - context.stopService(new Intent(context, FMRadioService.class)); + + if (isFmOn) { + Log.d(LOGTAG, "FM is still on"); + } else { + Log.e(LOGTAG, "stop FM radio service"); + context.stopService(new Intent(context, FMRadioService.class)); + } + if (sConnectionMap.isEmpty()) { // presumably there is nobody interested in the service at this point, // so don't hang on to the ServiceConnection