AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setInverseBackgroundForced(true);
AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setInverseBackgroundForced(false);In this code example, we create an instance of the AlertDialog.Builder class and set the inverseBackgroundForced property to false. This will respect the device's theme and set the dialog's background accordingly. Package library: android.app (part of the Android SDK)