i have android app which runs on mobile normally, but i need to make new design for this app for TV screen, this new design requires new widgets and new java code which is different from the code being used for mobile phone.
what is the best practice to do that? i already read about how to detect if the app is running on tv or mobile but i don't think this is the best practice to do that.
You can find whole info here https://developer.android.com/training/tv/start/start, but I would also share some pieces of advice:
This is the easiest way to find out the device's type:
val uiModeManager = getSystemService(UI_MODE_SERVICE) as UiModeManager
if (uiModeManager.currentModeType == Configuration.UI_MODE_TYPE_TELEVISION) {
//it is TV
} else {
//it is mobile
}