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

Commit 2837fbbe authored by Jake Hamby's avatar Jake Hamby Committed by Android (Google) Code Review
Browse files

Merge "Bluetooth : fix for crashing alertDialogbox"

parents ddf71724 bb16e15d
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -79,6 +79,10 @@ public final class LocalBluetoothManager {
        return mContext;
    }

    public Context getForegroundActivity() {
        return mForegroundActivity;
    }

    boolean isForegroundActivity() {
        return mForegroundActivity != null;
    }
+7 −1
Original line number Diff line number Diff line
@@ -89,11 +89,17 @@ final class Utils {

    static void showError(Context context, String name, int messageResId) {
        String message = context.getString(messageResId, name);
        new AlertDialog.Builder(context)
        LocalBluetoothManager manager = LocalBluetoothManager.getInstance(context);
        Context activity = manager.getForegroundActivity();
        if(manager.isForegroundActivity()) {
            new AlertDialog.Builder(activity)
                .setIcon(android.R.drawable.ic_dialog_alert)
                .setTitle(R.string.bluetooth_error_title)
                .setMessage(message)
                .setPositiveButton(android.R.string.ok, null)
                .show();
        } else {
            Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
        }
    }
}