diff options
author | Michael Bestas <mikeioannina@cyanogenmod.org> | 2016-02-12 02:58:58 +0200 |
---|---|---|
committer | Michael Bestas <mikeioannina@cyanogenmod.org> | 2016-02-12 13:32:30 -0800 |
commit | 95a503c41199230abaa46ad040d45527e9ccc052 (patch) | |
tree | f51a9abdc3efed224b83e7d9c2d2df5071cb14e3 /services/core/java/com/android/server/audio/AudioService.java | |
parent | f87c55083975a5360d8c32fb570e7e8186b5984c (diff) | |
download | frameworks_base-95a503c41199230abaa46ad040d45527e9ccc052.zip frameworks_base-95a503c41199230abaa46ad040d45527e9ccc052.tar.gz frameworks_base-95a503c41199230abaa46ad040d45527e9ccc052.tar.bz2 |
AudioService: Prevent crash when there is no music app
Change-Id: I45f22430a926da9b9254de8b58acd304b21fad41
Diffstat (limited to 'services/core/java/com/android/server/audio/AudioService.java')
-rw-r--r-- | services/core/java/com/android/server/audio/AudioService.java | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/services/core/java/com/android/server/audio/AudioService.java b/services/core/java/com/android/server/audio/AudioService.java index 7b5db46..2e24737 100644 --- a/services/core/java/com/android/server/audio/AudioService.java +++ b/services/core/java/com/android/server/audio/AudioService.java @@ -35,6 +35,7 @@ import android.bluetooth.BluetoothClass; import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothHeadset; import android.bluetooth.BluetoothProfile; +import android.content.ActivityNotFoundException; import android.content.BroadcastReceiver; import android.content.ComponentName; import android.content.ContentResolver; @@ -5133,10 +5134,14 @@ public class AudioService extends IAudioService.Stub { TelecomManager tm = (TelecomManager) mContext.getSystemService(Context.TELECOM_SERVICE); if (launchPlayer && !tm.isInCall()) { - Intent playerIntent = new Intent(Intent.ACTION_MAIN); - playerIntent.addCategory(Intent.CATEGORY_APP_MUSIC); - playerIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - mContext.startActivity(playerIntent); + try { + Intent playerIntent = new Intent(Intent.ACTION_MAIN); + playerIntent.addCategory(Intent.CATEGORY_APP_MUSIC); + playerIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + mContext.startActivity(playerIntent); + } catch (ActivityNotFoundException | IllegalArgumentException e) { + Log.w(TAG, "No music player Activity could be found"); + } } } |