问题
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
回答1:
We can install the android app in two ways.
- adb install command
- 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.
回答2:
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.
回答3:
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.
回答4:
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
来源:https://stackoverflow.com/questions/14846609/restrict-app-installing-in-tablets