I want to make a function on my application that will know whether it is a tablet or a mobile phone.

To if this is a tablet, it is in setContentView(R.layout.movie_activity); changed to movie_activity2 .

  • As far as I remember, in Android Studio, the standard template with activation includes the separation of the smartphone / tablet markup - a single-panel interface / two-panel. But you can make any differences in your markup for this template. - pavlofff
  • and why is it even necessary? - redL1ne
  • If you are given an exhaustive answer, mark it as correct (a daw opposite the selected answer). - Nicolas Chabanovsky

1 answer 1

You are in the wrong direction . The fact is, I would venture to suggest that you need to show content that is differently located on different sized devices.

For this there are different qualifiers for layouts - ( layout-mdpi, layout-hdpi, layout-small and etc.). For the tablet, you need to specify the following qualifier - layout-w600dp (you can play with the size).

Once you have conceived different layout- s, then I suppose they differ not only in line-up, but also in content. For example, on the tablet there is an add. views with aidishniki, this is also solved with the help of checks in the code or a special viewview - ViewStub.

  • Google calls them not locales but qualifiers - pavlofff
  • already corrected. =) - s_klepcha