I have an Android device with 2 displays and I need to set the second display's DPI programmatically. It works with the following command over ADB (and then perform a restart to see the changes) :
wm density 160 -d 1
but when I try to programmatically run this command (and then restart the device):
try {
Runtime.getRuntime().exec("wm density "+Constants.DPI_TO_SET_DEVICE_TO+" -d 1");
} catch (IOException e) {
throw new RuntimeException(e);
}
nothing seems to happen. Am I doing something wrong here? I've also researched using DisplayMetrics to do this programmatically as well, but that doesn't seem to be able to set a second display DPI that I'm aware of. Am I misunderstanding that?