From 838535ec9c3300da37f91316c086a948c66d021f Mon Sep 17 00:00:00 2001 From: Raph Levien Date: Thu, 19 Dec 2013 13:52:00 -0800 Subject: [PATCH] Only unregister USB receiver if it was registered This will probably prevent a crash on pre-Honeycomb devices. --- .../src/com/levien/synthesizer/android/ui/PianoActivity2.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/android/src/com/levien/synthesizer/android/ui/PianoActivity2.java b/android/src/com/levien/synthesizer/android/ui/PianoActivity2.java index e8b1da8..9281bf0 100644 --- a/android/src/com/levien/synthesizer/android/ui/PianoActivity2.java +++ b/android/src/com/levien/synthesizer/android/ui/PianoActivity2.java @@ -189,7 +189,9 @@ public class PianoActivity2 extends Activity { protected void onPause() { Log.d("synth", "activity onPause"); androidGlue_.setPlayState(false); - unregisterReceiver(usbReceiver_); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1) { + unregisterReceiver(usbReceiver_); + } setMidiInterface(null, null); super.onPause(); }