Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you specify in AndroidManifest.xml that you want to forbid installing on devices smaller than a 4.7-inch device?

I have a game that feels best on 7-inch tablets, and feels acceptably nice on 10-inch tablets and 5-inch Samsung Note-size devices. It's even just passably fun on something the size of a Nexus 4 phone or an S3. It is not at all fun to play on anything smaller. That being the case, how can a Manifest be written such that it can install on anything from a 4.7-inch device to a 10-inch tablet while being restricted from smaller phones?

EDIT

Stepping back for a moment, the reason for this question is because I find the documentation on the Android developer website to be incredibly confusing and conflicting. Let's give some examples to show just where the confusion comes from :

Let's take for example a couple of different devices.

Droid 3

  • 4-inch display
  • 540x960 px
  • 275 ppi

Looking at the documentation for supports-screens, we can infer that...

  • At 4 inches it may be on the bare edge of "large" but probably medium
  • At 540x960 it is well within the minimum for "large"
  • at 275 ppi it claims to be an hdpi screen

However, this device is far smaller than one that I would want to support... but the documentation makes it seem like on 2 of 3 counts, this device has a "Large" screen. By no sane definition of the term is a 4-inch screen "Large." Now, let's go further...

Nexus 4

  • 4.7 inch display
  • 768x1280 px
  • 318 ppi

Looking at the documentation for supports-screens, we can infer that...

  • This screen's physical dimensions are right on the border of Medium and Large
  • The pixel dimensions would indicate that it could be xlarge
  • The ppi indicate that it is an xhdpi device

Again, by no sane definition is a 4.7 inch screen "xlarge"... The screen's size is possibly just large enough to make the game enjoyable, but is it a "medium" screen? A "large" screen? How can you possibly know?

Would both of the above phones be "Medium"? Would the Droid be "Medium" while the Nexus "Large"? Why or why not? And if the Nexus is "Large" then how is that distinct from a 7 inch tablet, which also should be "Large?"

And then there's the fact that the docs claim that supports-screens/size is deprecated as of 3.2 anyway

But then there's no clear guidance on what to use in its place if one wants to support both old phones (assuming proper physical screen size in inches) and new tablets, or if there is it's hidden well out in the woods. Can someone lay out clearly what cretieria really matter and why a given device will fit a given filter or fail it?

like image 535
scriptocalypse Avatar asked Jan 28 '13 20:01

scriptocalypse


People also ask

How do I change AndroidManifest XML?

Open your Android project and go to <AppProjectFolder>/app/src/main/. Open the app manifest file AndroidManifest. xml and add the following lines to the file as child elements of the <manifest> element. Note: You must include the QUERY_ALL_PACKAGES permission if your app targets Android 11 (API Level 30) or higher.

How do you limit which Android devices can download your app?

Set up device exclusion rules for Android (Go edition)Select the Excluded devices tab. Next to "Exclusion rules," select Manage exclusion rules. Don't exclude Android Go devices: Selected by default. Exclude Android Go devices: Prevent devices running Android Oreo (Go edition) from installing your app on Google Play.

What is AndroidManifest XML write its usage with an appropriate example?

Every app project must have an AndroidManifest. xml file (with precisely that name) at the root of the project source set. The manifest file describes essential information about your app to the Android build tools, the Android operating system, and Google Play.

Which attribute in the AndroidManifest XML is used to give the app name?

The main component of the AndroidManifest. xml file is known as manifest. Additionally, the package field describes the activity class's package name. It must contain an <application> element with the xmlns:android and package attribute specified.

What is AndroidManifest XML and what should we include in it?

The AndroidManifest. xml file contains information of your package, including components of the application such as activities, services, broadcast receivers, content providers etc.


1 Answers

I think based on Google docs this will serves your requirements (5" and smaller):

<compatible-screens>

    <screen android:screenSize="large" android:screenDensity="ldpi" />
    <screen android:screenSize="large" android:screenDensity="mdpi" />

    <screen android:screenSize="xlarge" android:screenDensity="ldpi" />
    <screen android:screenSize="xlarge" android:screenDensity="mdpi" />
    <screen android:screenSize="xlarge" android:screenDensity="hdpi" />
    <screen android:screenSize="xlarge" android:screenDensity="xhdpi" />

</compatible-screens>

Or using this (4.7" and smaller):

<supports-screens android:smallScreens="false"
                  android:normalScreens="true"
                  android:largeScreens="true"
                  android:xlargeScreens="true"
                  android:requiresSmallestWidthDp="536" />

I recommend the second method because it is more accurate.

How 536 is calculated ? Based on http://developer.android.com/guide/practices/screens_support.html we have (height x width):

  • xlarge screens are at least 960dp x 720dp
  • large screens are at least 640dp x 480dp
  • normal screens are at least 470dp x 320dp
  • small screens are at least 426dp x 320dp

(720 - 480) / (7 - 4) = 80, 480 + (80 * 0.7) = 536

And do not worry about "deprecated warning", since the new suggested method is for tablet apps (IMO) which the UI is not full-screen and some spaces from bottom and top of screen occupied for Title-bar and/or back, menu etc. buttons while your game probably runs in full screen mode.

Check this from Google docs at http://developer.android.com/guide/practices/screens_support.html#DeclaringTabletLayouts :

Note: The sizes that you specify using these qualifiers are not the actual screen sizes. Rather, the sizes are for the width or height in dp units that are available to your activity's window. The Android system might use some of the screen for system UI (such as the system bar at the bottom of the screen or the status bar at the top), so some of the screen might not be available for your layout. Thus, the sizes you declare should be specifically about the sizes needed by your activity—the system accounts for any space used by system UI when declaring how much space it provides for your layout. Also beware that the Action Bar is considered a part of your application's window space, although your layout does not declare it, so it reduces the space available for your layout and you must account for it in your design.

like image 107
FatDog47 Avatar answered Oct 06 '22 00:10

FatDog47