8 Jan 2013

Create an application for both tablet and mobile in android | Filter Application in Google play | compatible-screens in android

There are so many thing is to consider while Making app for tablets and mobile, here is configuration setting for Application.
-Images for Various Resolution Screens Visit:  Support screens.

1.Developing app for Mobile.

if your application is compatible with only small and normal screens, regardless of screen density, then you must specify eight different <screen> elements, because each screen size has four density configurations. You must declare each one of these; any combination of size and density that you do not specify is considered a screen configuration with which your application is not compatible. Here's what the manifest entry looks like if your application is compatible with only small and normal screens:
<manifest ... >
    <uses-sdk android:minSdkVersion="4" />
    <uses-sdk android:maxSdkVersion="10" />
   <application ... ><application>
</manifest>

The <compatible-screens> element must contain one or more <screen> elements, which each specify a screen configuration with which your application is compatible, using both the android:screenSize andandroid:screenDensity attributes. Each <screen> element must include both attributes to specify an individual screen configuration—if either attribute is missing, then the element is invalid (external services such as Google Play will ignore it).

<manifest ... >
    <compatible-screens>
        <!-- all small size screens -->
<screen android:screenSize="small" android:screenDensity="ldpi" />
<screen android:screenSize="small" android:screenDensity="mdpi" />
<screen android:screenSize="small" android:screenDensity="hdpi" />
<screen android:screenSize="small" android:screenDensity="xhdpi" />
<!-- all normal size screens -->
<screen android:screenSize="normal" android:screenDensity="ldpi" />
<screen android:screenSize="normal" android:screenDensity="mdpi" />
<screen android:screenSize="normal" android:screenDensity="hdpi" />
<screen android:screenSize="normal" android:screenDensity="xhdpi" />
</compatible-screens>    <application ... >    <application>
</manifest>

2.Developing app for Tablets.

2.1 Declare the minimum system version.
The first thing to do when you upgrade or create a project for Android 3.0 is set your manifest's android:minSdkVersion to"11". This declares that your application uses APIs available in Android 3.0 and greater, so it should not be available to devices running an older version of Android. For example:
<manifest ... >
    <uses-sdk android:minSdkVersion="11" />
    <application ... >..
    <application>
</manifest>
 
if you want your application to be available only to extra large screens, you can declare the element in your manifest like this:
<manifest ... >  ...
    <supports-screens android:smallScreens="false"
                      android:normalScreens="false"
                      android:largeScreens="false"
                      android:xlargeScreens="true" />
    <application ... >...
    <application>
</manifest>
2.2 Enable hardware acceleration.
Android 3.0 adds a hardware-accelerated OpenGL renderer that gives a performance boost to most 2Dgraphics operations.You can enable hardware-accelerated rendering in your application by settingandroid:hardwareAccelerated="true" in your manifest's <application> element or for individual<activity> elements. Hardware acceleration results in smoother animations, smoother scrolling, and overall better performance and response to user interaction. When enabled, be sure that you thoroughly test.your application on a device that supports hardware acceleration.
2.3 Using telephony or other variable features.
Tablets and similar devices might not include support for telephony, so they can't make traditional phone calls or handle SMS. Some devices might also omit other hardware features, such as Bluetooth. If your application uses these features, then your manifest file probably already includes (or should include) a declaration of the feature with the <uses-feature> element. Doing so prevents devices that do not declare support for the feature from downloading your applications. For example:
<uses-feature android:name="android.hardware.telephony" />
By default, this declares that your application requires telephony features.So, external services such as Google Play use this information to filter your application from devices that do not offer telephony.If, however, your application uses, but does not require the feature, you should add to this element,android:required="false". 
For example:
<uses-feature android:name="android.hardware.telephony" android:required="false" />
<uses-feature android:name="android.hardware.camera" android:required="false" />
<uses-feature android:name="android.hardware.bluetooth" android:required="false" />
This indicates that your application uses the feature,but is still functional if the feature
is not available. So,it should still be available to devices that don't provide telephony hardware (or telephony features), such as tablets.Then in your application code,you 
must gracefully disable the features that use telephony when it's not available.
Then in your application code, you must gracefully disable the features that use telephony when it's not available. You can check whether the feature is available using PackageManager.hasSystemFeature(). For example:
PackageManager pm = getPackageManager();
boolean hasTelephony = pm.hasSystemFeature(PackageManager.FEATURE_TELEPHONY);

Quick Implementation:

Here is Filter for both tablet and device:(Set below Filer in AndroidManifest.xml )

1. Application for Device only :

<compatible-screens>
<!-- all small size screens -->
<screen android:screenSize="small" android:screenDensity="hdpi" />
<screen android:screenSize="small" android:screenDensity="xhdpi" />
<screen android:screenSize="small" android:screenDensity="480" />
<!-- all normal size screens -->
<screen android:screenSize="normal" android:screenDensity="hdpi" />
<screen android:screenSize="normal" android:screenDensity="xhdpi" />

<screen android:screenSize="normal" android:screenDensity="480" />

Note : here 480 is consider for devices like S3 , S4, Samsung note,Nexus etc.

2. Application for Tablets only :
<supports-screens
        android:largeScreens="true"
        android:normalScreens="false"
        android:requiresSmallestWidthDp="600"
        android:smallScreens="false"

        android:xlargeScreens="true" />

    <uses-sdk
    android:minSdkVersion="11"
    android:targetSdkVersion="14" />

Note : Set development api level of application as 4.0.

Filter app by Google play visit 


I will be happy if you will provide your feedback or follow this blog. Any suggestion and help will be appreciated.
Thank you :)

4 comments:

  1. Hi ,

    Thankyou for the post .

    I need some help .I want to support my android app only for handsets not for 7 inch and 10 inch tablets.
    I used my below code in the application manifest file, but the play store

    showing on all devices and let me to install in tablets also which i don't

    want.

    I want to use only for handsets . Thankyou.



















    ReplyDelete
    Replies
    1. Hello,

      First of all you need to set below properties as per your requirement. and you need to set support screen android:xlargeScreens="false" then it will effect after live on Google play. below is code for you, Enjoy :)









      Delete
  2. This comment has been removed by the author.

    ReplyDelete
  3. Hello Mic WP,

    i have updated post, now you can directly get idea in Quick Implementation in my post.

    Let me know even you have any query

    ReplyDelete