1

How can I create a project in Android Studio for phones and tablets, where the APK on the Play Store is the same for both?

I am using build variants with build flavors, but there are two APKs for every device.

S.S. Anne
  • 15,171
  • 8
  • 38
  • 76
  • 1
    By default your `.apk` will work on both. The question is how it will look like if don't design `layout`s for both separately. – Yurets May 06 '15 at 15:34
  • yes, my layouts they are created separate every one, and values for every device, but the activity's they are created in build flavor main or build phone or buid tablet. – Jaive Torres Pineda May 06 '15 at 15:39
  • The logic shouldn't be the matter, if your app hasn't some specific behavior... hm... like "if you use tablet - you don't need to register", so you don't have anything to worry about. Main problem in this question - `layout`s. If you say there is everything ok, so just upload it. Or do you have anything specific in logic targeted exactly to the phone or tablet? – Yurets May 06 '15 at 15:43

1 Answers1

0

You can just approximate if it's a tablet or not by checking the screendimension. If the app uses XLARGE or LARGE display dimensions, it could be a tablet or a "big" phone.

You can get informations about that with something like this:

if(getResources().getConfiguration().screenLayout == Configuration.SCREENLAYOUT_SIZE_LARGE 
|| getResources().getConfiguration().screenLayout == Configuration.SCREENLAYOUT_SIZE_XLARGE) {
    //doSomething
}

You can test which of these ones is the better one for you.

more reference:

Designing Android apps for tablets

Different GUI on phone and tablet, but same app problem

Community
  • 1
  • 1
Ranjithkumar
  • 16,071
  • 12
  • 120
  • 159