May 22, 2011

How to Pass Intent to Browser in Android

Intent intent = new Intent("android.intent.action.VIEW", Uri.parse(stringurl));
startActivity(intent);

May 17, 2011

How to Hide Title Bar in Android Application

  To hide the title bar through out application we have to include android:theme attribute to application tag in the Andriod Manifast.xml


 <application android:name="TestApplication" android:theme="@android:style/Theme.NoTitleBar">


Then in entire application title bar was not visible.

May 15, 2011

How to Get Current Screen Orientation In Android

The following example gives the current screen orientation.

public int getScreenOrientation()
{
        return getResources().getConfiguration().orientation;
}

The above method return integer. We will compare as follows.

 if(getScreenOrientation() == Configuration.ORIENTATION_PORTRAIT)
 {
            //App is in Portrait mode
 }
 else
{
           //App is in LandScape mode
}

May 11, 2011

How to Check Availability of Wi-Fi through Android

 The following method Return whether Wi-Fi is enabled or disabled.
 True if enabled otherwise false.
 
 public boolean checkWIFI()
 {
        WifiManager wm = (WifiManager) getSystemService(Context.WIFI_SERVICE);
        return wm.isWifiEnabled();
 }