Why does a text box appear behind the Bluetooth permission dialog for my Android app?

906 views Asked by At

I am writing an app that requires Bluetooth to be enabled to use and there is a strange "title like" set of text that appears behind the alert dialog that asks to enable Bluetooth. The text says "Bluetooth Permission Request" in big bold letters and once the alert dialog disappears this text does as well like half a second later. Anyone know why this text is popping up and or how to get rid of it?

Here's my code that sets up the intent.

private void ensureBluetoothEnabled() {
    switch (mRxBleClient.getState()) {
        case BLUETOOTH_NOT_ENABLED:
            Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
            startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
            break;
        case READY:
            showScanFragment();
    }
}

And this is the code that runs after.

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if(requestCode == REQUEST_ENABLE_BT) {
        if(RESULT_OK == resultCode)
            showScanFragment();
        else
            new AlertDialog.Builder(this).setMessage("Bluetooth is required to use this service.")
                    .setPositiveButton("OK", (dialog, which) -> {
                        ensureBluetoothEnabled();
                        dialog.dismiss();
                    });
    }
}

enter image description here

enter image description here

Permissions code

private static final int REQUEST_PERMISSIONS = 10;

private static final String[] PERMISSIONS = new String[]{
        Manifest.permission.BLUETOOTH,
        Manifest.permission.BLUETOOTH_ADMIN,
};

@Override
protected void onCreate(Bundle savedInstanceState) {
    ((MainApplication) getApplication()).getRxBleClientComponent().inject(this);

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    requestPermissions(PERMISSIONS, REQUEST_PERMISSIONS);
}

@Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
    super.onRequestPermissionsResult(requestCode, permissions, grantResults);
    for(int i : grantResults)
        if(i == PackageManager.PERMISSION_DENIED) {
            Toast.makeText(this, "All permissions are required. App will close.", Toast.LENGTH_LONG).show();
            finish();
            return;
        }

    ensureBluetoothEnabled();
}
0

There are 0 answers