Is there a way to have two different Java codes for the same Android application? One targeting phone devices and other targeting tablet devices.
For example, something like HomeActivity.java and HomeActivity-large.java
Basically, I would like to make an Android app that has a different layout, following its resolution.
I know that I can use layout-large to have a specific layout for large devices. I'm not sure how to have specific logic for tablets and another for phone purposes.
The reason I want to do this is because I would like to make an API call on a screen that I don't want to do on the phone.
As an alternative way, I thought of using a boolean (I'm not sure which one) to check which device the application is running on. But I am afraid that this may become promiscuous.
Another thing could be to create a library with all the features of my application, and then with two different applications using the library. The problem with this solution is that some code will be replicated.
Any suggestion?
source share