问题
Though this question is asked before many a times, I am not able to find any proper solution to it.
I just want my application to be installed on tablets. I already have the same application for phone and now I want it to be installed on tablets. My UI for tablet is totally different than phone.
Play Store has now added a option of "Featured Apps for Tablets". I checked this
Should I develop another application featured for only tablet, by adding <supports-screens android:requiresSmallestWidthDp="600">?
But I have read here ,that google play doesn't filter with the tag requiresSmallestWidthDp.
Seeing this Phones are picking tablet build from Android play store if i use android:largeScreens="true" phones like Note2, Grand, Nexus-4 could pick the tablet build. But I jst want screen > 7 inches should install my application. Other should not show install button in play store.
As this option doesn't seem to be working, then how could I start with? Is there any restriction on manifest which I could use so that app would only be installed in tablets?
Another way around I found that to make a universal application for phone and tablet. And apply any condition checking on screen size of device. According to screen size I could differentiate the flow one for tablet and another for phone.
I am totally confused, which way should be best possible to go. Any guidance or hint would help me a lot in taking a proper decision.
回答1:
As pointed out on the Best Practices section of the Android developer site:
If you don't want your app to be used on handsets (perhaps your app truly makes sense only on a large screen) or you need time to optimize it for smaller screens, you can prevent small-screen devices from downloading your app by using the <supports-screens> manifest element.
So, what you'll want to do is decide what screen size you consider to be tablets-on-up and only support those screens. For example, as suggested by the dev. site again, you might limit it to only large screens and larger¹ with the <supports-screen> element in your manifest, like so (also borrowed from the Android dev site):
<supports-screens
android:smallScreens="false"
android:normalScreens="false"
android:largeScreens="true"
android:xlargeScreens="true"
android:requiresSmallestWidthDp="600"
/>
This doesn't guarantee your app won't run on certain classes of very large phones ("phablets" as the youngsters like to call 'em), but that's just the nature of trying to limit it based on something as arbitrary in Android development as phone vs. tablet, especially when the real difference is just screen size. I could also mention that it's better to just build the tablet UI into your app, but that might involve some additional work depending on how different the two UIs are.
At any rate, your main problem is just going to be to decide how small is too small and limit it accordingly. Google Play should respect lower bounds for the screen size, but upper bounds in the <supports-screens> element will be ignored on larger screens, as the app will be run in compatibility mode instead. To prevent larger screens, for whatever reason, you'll want to use <compatible-screens>, which you probably won't want to do unless your UI is completely inflexible for some reason.
¹ This sounds weird.
回答2:
<supports-screens
android:largeScreens="true"
android:normalScreens="false"
android:requiresSmallestWidthDp="600"
android:smallScreens="false"
android:xlargeScreens="true" />
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="14" />
To get HoneyComb Tablets aswell you simply change your minSdk
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="14" />
Thus phones with gingerbread and below cannot download your app
There are no phones with honeycomb(api 11)
and finally
ICS Tablets are supported because it does look at your smallestWidth attribute
and finally ICS phones aren't because as we say ICS uses the smallestWidth attribute
回答3:
But I have read here http://developer.android.com/guide/topics/manifest/supports-screens-element.html ,that google play doesn't filter with the tag requiresSmallestWidthDp.
It's true only for 3.2. You can use the following I suppose as mentioned in this article.
<manifest ... >
<supports-screens android:smallScreens="false"
android:normalScreens="false"
android:largeScreens="true"
android:xlargeScreens="true"
android:requiresSmallestWidthDp="600" />
...
<application ... >
...
</application>
</manifest>
If your UI is totally different, I would suggest you have a re-look as the same user can user the same app on both phones and tablets. Also, maintaining a different code base might be quite a task. I would suggest you optimize the same app for tablets too. Fragments are meant and designed for the exact same purpose.
In case Google Play still shows your app for devices like Note, you can have the following in your Tablet only app:
Put config.xml file in values folder containing:
<bool name="isTablet">false</bool>
Put config.xml file in values-sw600dp folder containing:
<bool name="isTablet">true</bool>
MainActivity's Code:
onCreate(Bundle bundle){
if(!getResources().getBoolean(R.bool.isTablet)){
// Direct User to the phone version of the app.
}
}
One more thing: When you upload to the Play Store, you are given a list of devices which can download that app based on your manifest. You can uncheck Note kind of devices there. One catch is if the next day a new Note kind of devices come to the market, that device will still be able to download that app unless you update your supported devices list regularly.
来源:https://stackoverflow.com/questions/20185123/develop-application-only-for-tablet