Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 95a503c4 authored by Michael Bestas's avatar Michael Bestas
Browse files

AudioService: Prevent crash when there is no music app

Change-Id: I45f22430a926da9b9254de8b58acd304b21fad41
parent f87c5508
Loading
Loading
Loading
Loading
+9 −4
Original line number Diff line number Diff line
@@ -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()) {
            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");
            }
        }
    }