6

I have an Android application and I want to stop this app installing in Tablet. I have searched many websites. I got some ideas and followed that. But that is not restricting.

Here are the some of sites that i have visited.

Android Manifest Restrict To Tablets

http://android-developers.blogspot.in/2011/09/preparing-for-handsets.html

I have tried with supports-screens still app is installing in Tablet. How to do this?

Note: My app having minsdkversion = 8 and targetsdkversion = 17

EDIT 1: I have used the following code to find the screen size

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

WindowManager wm=getWindowManager();
DisplayMetrics dm=new DisplayMetrics();
wm.getDefaultDisplay().getMetrics(dm);
deviceWidth=dm.widthPixels;
deviceHeight=dm.heightPixels; 
if((deviceHeight< 640 && deviceWidth<480)|| (deviceHeight<480 && deviceWidth< 640))
  {
      //large screen - TABLET

  }

But i don't know where to put this code to restricts installation and what will be the code to stop installation if large screen is true.

EDIT2: Target device in iOS will be IPAD/IPHONE/UNIVERSAl, like that I want to set in Android app

Community
  • 1
  • 1
Ponmalar
  • 6,871
  • 10
  • 50
  • 80

4 Answers4

2

We can install the android app in two ways.

  1. adb install command
  2. From Google Play store

Using the adb install command, No one can restrict the app installation only to tablets or phone. The , and so on in the manifest settings file is only applicable for the Google Play store filter. We can restrict the app installation to certain device by when you upload your APK at Market see All Applications > select your application > APK > Supported devices | Excluded devices.

Karthick
  • 1,241
  • 5
  • 20
  • 43
0

Nobody really wants you to do that so it may be a little tricky. You can disable specific devices in Google Play's developer console but as there are thousands, it may be a long list to cover. Still, you can use the console's search for Tab, pad, tablet and nexus 7,10 and that may cover a large portion of those devices.

Another option to consider is actually setting the target sdk to a pre honeycomb level. That said, note it may though impair your app's functionality.

Ben Max Rubinstein
  • 1,803
  • 1
  • 13
  • 15
0

A quick and dirty way to do it would be to add to your manifest the following line:

<uses-feature android:name="android.hardware.telephony" android:required="true" />

While strictly speaking this only enforces that your app will be to devices that have voice radio, in practice it will serve your purpose, as almost no tablets have phone functionality. One notable exception however is Samsung Galaxy Note II which is a 5.5" phone, so technically it's somewhere between phone and tablet form factor.

Franci Penov
  • 74,861
  • 18
  • 132
  • 169
  • My answer is based on the assumption that you want to *prevent your app from installing on tablets*. If I have misunderstood you, that answer will not work for you. – Franci Penov Feb 13 '13 at 05:14
  • Thanks for your response. Let me try with this – Ponmalar Feb 13 '13 at 06:13
  • @Ponmalar and by "installs on tablets" do you mean "people can install it from Google Play store on tablets" or "I can use `adb install` to push it to my tablet"? Nothing can prevent the latter. The only verification that `PackageManager` will do is the API level in the manifest of the app. – Franci Penov Apr 09 '13 at 07:12
  • @Ponmalar With regards to your _EDIT1_ there is no application code that runs during the installation. You could put this code in your `Application.onCreate()` and prevent the app from running, but you can't prevent it from being installed using code. – Franci Penov Apr 09 '13 at 07:13
  • @Ponmalar that code is available to you only on Runtime, therefore it's irrelevant to you case. What is the question for EDIT2? – Ben Max Rubinstein Apr 09 '13 at 09:18
0

Keep in mind that Google Play distribution might take a while. Uploading a new application by the console is not reflected immediately on your device.

It might takes a couple of hours, one might miss the right solution.

Hope this helps. Yaron

Yaron Reinharts
  • 213
  • 1
  • 7