25 Jan 2013

How to get thumbnail of YouTube video link using YouTube API in Android.

Each YouTube video has 4 generated images. They are predictably formatted as follows:

http://img.youtube.com/vi/<insert-youtube-video-id-here>/0.jpg
http://img.youtube.com/vi/<insert-youtube-video-id-here>/1.jpg
http://img.youtube.com/vi/<insert-youtube-video-id-here>/2.jpg
http://img.youtube.com/vi/<insert-youtube-video-id-here>/3.jpg

The first one in the list is a full size image and others are thumbnail images. The default thumbnail image (ie. one of 1.jpg, 2.jpg, 3.jpg) is:

http://img.youtube.com/vi/<insert-youtube-video-id-here>/default.jpg

For the high quality version of the thumbnail use a url similar to this:
http://img.youtube.com/vi/<insert-youtube-video-id-here>/hqdefault.jpg

There is also a medium quality version of the thumbnail, using a url similar to the HQ:
http://img.youtube.com/vi/<insert-youtube-video-id-here>/mqdefault.jpg

For the maximum resolution version of the thumbnail use a url similar to this:
http://img.youtube.com/vi/<insert-youtube-video-id-here>/maxresdefault.jpg

All of the above urls are available over https too. Just change http to https in any of the above urls.

Alternatively, you can use the YouTube API to get thumbnail images.
String img_url="http://img.youtube.com/vi/WLBuJfaaGD8/default.jpg";

public void DownloadThumbnailImageYoutubeVideo(final String imgurl)
      {      
         new Thread(new Runnable()
           {
             public void run()
              {
               try
                {
                 final Bitmap bitmap = BitmapFactory.decodeStream((InputStream) new URL(imgurl).getContent());
                   imgView.post(new Runnable()
                     {
                       @Override
                       public void run()
                      {
                         if(bitmap !=null)
                         {                            
                             imgView.setImageBitmap(bitmap);                                          
                          }  

                       }
                      });
                 } 
                  catch (Exception e)
                  {}
               }
         }).start(); 
       }

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

Thank you :)

11 Jan 2013

Filtering App in Google play.

There are so many feature consider while searching application in Google play. here i have find some importants feature which is most used in Application development. Hop this will help you Thanks.
Filtering based on explicit features
·         If a feature is explicitly declared as being required, Google Play adds the feature to the list of required features for the application. It then filters the application from users on devices that do not provide that feature. For example:
<uses-feature android:name="android.hardware.camera" android:required="true" />
·         If a feature is explicitly declared as not being required, Google Play does not add the feature to the list of required features. For that reason, an explicitly declared non-required feature is never considered when filtering the application. Even if the device does not provide the declared feature, Google Play will still consider the application compatible with the device and will show it to the user, unless other filtering rules apply. For example:
<uses-feature android:name="android.hardware.camera" android:required="false" />
·         If a feature is explicitly declared, but without an android:required attribute, Google Play assumes that the feature is required and sets up filtering on it.
In general, if your application is designed to run on Android 1.6 and earlier versions, the android:requiredattribute is not available in the API and Google Play assumes that any and all <uses-feature> declarations are required.
Note: By declaring a feature explicitly and including an android:required="false" attribute, you can effectively disable all filtering on Google Play for the specified feature.

Filtering based on implicit features
An implicit feature is one that an application requires in order to function properly, but which is not declared in a<uses-feature> element in the manifest file. Strictly speaking, every application should always declare all features that it uses or requires, so the absence of a declaration for a feature used by an application should be considered an error. However, as a safeguard for users and developers, Google Play looks for implicit features in each application and sets up filters for those features, just as it would do for an explicitly declared feature.
An application might require a feature but not declare it because:
·         The application was compiled against an older version of the Android library (Android 1.5 or earlier) and the<uses-feature> element was not available.
·         The developer incorrectly assumed that the feature would be present on all devices and a declaration was unnecessary.
·         The developer omitted the feature declaration accidentally.
·         The developer declared the feature explicitly, but the declaration was not valid. For example, a spelling error in the <uses-feature> element name or an unrecognized string value for the android:name attribute would invalidate the feature declaration.
To account for the cases above, Google Play attempts to discover an application's implied feature requirements by examining other elements declared in the manifest file, specifically, <uses-permission> elements.
If an application requests hardware-related permissions, Google Play assumes that the application uses the underlying hardware features and therefore requires those features, even though there might be no corresponding to <uses-feature> declarations. For such permissions, Google Play adds the underlying hardware features to the metadata that it stores for the application and sets up filters for them.
For example, if an application requests the CAMERA permission but does not declare a <uses-feature> element for android.hardware.camera, Google Play considers that the application requires a camera and should not be shown to users whose devices do not offer a camera.
If you don't want Google Play to filter based on a specific implied feature, you can disable that behavior. To do so, declare the feature explicitly in a <uses-feature> element and include an android:required="false"attribute. For example, to disable filtering derived from the CAMERA permission, you would declare the feature as shown below.
<uses-feature android:name="android.hardware.camera" android:required="false" />

Create app for headset and tablet filter visit

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

Thank you :)

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 :)

3 Jan 2013

Check whether the device is Tablet or Phone - Android

Solution1: calculate the size of the screen and use that to make the decision whether the device is a phone or tablet?


public boolean isTablet(Context context)
    {
boolean xlarge = ((context.getResources().getConfiguration().screenLayout &       Configuration.SCREENLAYOUT_SIZE_MASK) == 4);
boolean large = ((context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_LARGE);
        return (xlarge || large);
    }


Solution2: calculate the size of the screen diagonal and use that to make the decision whether the device is a phone or tablet?


public boolean isTablet()
       {
              try
              {
                     // Compute screen size
                     DisplayMetrics dm = context.getResources().getDisplayMetrics();
                     float screenWidth  = dm.widthPixels / dm.xdpi;
                     float screenHeight = dm.heightPixels / dm.ydpi;
                     double size = Math.sqrt(Math.pow(screenWidth, 2) + Math.pow(screenHeight, 2));
                     // Tablet devices should have a screen size greater than 6 inches
                     return size >= 9.0;
              }
              catch(Throwable t)
              {
                     Log.error(TAG_LOG, "Failed to compute screen size", t);
                     return false;
              }
       }


 Solution3: determine the oreintation of the device and use that to make the decision whether the device is a phone or tablet?


  
private static boolean isTablet(Display display)
    {
           Log.d(TAG, "isTablet()");
           final int width = display.getWidth();
           final int height = display.getHeight();

           switch (display.getOrientation())
           {
           case 0: case 2:
                  if(width > height) return true;
                  break;
           case 1: case 3:
                  if(width < height) return true;
                  break;
           }
           return false;
    }

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