0

I am developing an android app which a design that needs at least 3,5 inches. I know that this property "android:requiresSmallestWidthDp" exists but I can't use it because my app is avalaible from api level 8.

So... is there any way of prevent my app from being installed or downloaded if the devices hasn't got a screen with 3,5 inches?

2 Answers2

1

I know that this property "android:requiresSmallestWidthDp" exists but I can't use it because my app is avalaible from api level 8.

android:requiresSmallestWidthDp is not used. Quoting the documentation:

Caution: The Android system does not pay attention to this attribute, so it does not affect how your application behaves at runtime. Instead, it is used to enable filtering for your application on services such as Google Play. However, Google Play currently does not support this attribute for filtering (on Android 3.2), so you should continue using the other size attributes if your application does not support small screens.

 

So... is there any way of prevent my app from being installed or downloaded if the devices hasn't got a screen with 3,5 inches?

No. You can use <compatible-screens> to limit yourself to small screens, which will be under 3 inches, but you will miss out on devices with screens from 3 to 3.5 inches.

Also note that not that many devices have screen sizes that small.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
1

While sir commonsware is probably right which he almost always is I beg to differ. You can try to get the device inch size during first running of your application to check if its greater than 3.5 inches. Here's some code taken from this SO post.

DisplayMetrics dm = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(dm);
int width=dm.widthPixels;
int height=dm.heightPixels;
int dens=dm.densityDpi;
double wi=(double)width/(double)dens;
double hi=(double)height/(double)dens;
double x = Math.pow(wi,2);
double y = Math.pow(hi,2);
double screenInches = Math.sqrt(x+y);
if(screenInches>3.5){
//run the app
}else{
//show app incompatible message note that you might get bad rating in play store I gave it to youtube app today
}
Community
  • 1
  • 1
Illegal Argument
  • 10,090
  • 2
  • 44
  • 61
  • This method is useful to prevent from running but not from installing which is I am looking for. I think if I use this code some users could feel angry and give me a negative rating... Thanks –  Jun 14 '14 at 13:50
  • 1
    I mentioned that in my comments. But as @Commonsware correctly said the answer is no. My answer is of the type something is better than nothing. – Illegal Argument Jun 14 '14 at 13:53