Showing posts with label manifest. Show all posts
Showing posts with label manifest. Show all posts

Saturday, September 24, 2011

Android - Stop/Disable Orientation

Add the Following Lines:

In AndroidManifest.xml


Find the Activity section in which you want stop/disable the orientation and add the following attribute


android:configChanges="keyboardHidden|orientation"


In the Activity(In which you want to stop/disable orientation) class add the following code:



@Override
    public void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    }

Saturday, September 17, 2011

Get IPAddress On Your Android Device


WifiManager wifiManager = (WifiManager) getSystemService(WifiInfo wifiInfo = wifiManager.getConnectionInfo();
 ipAddress = wifiInfo.getIpAddress();
 SIpaddress =  String.format("%d.%d.%d.%d", (ipAddress & 0xff),(ipAddress >> 8 & 0xff),
    (ipAddress >> 16 & 0xff),(ipAddress >> 24 & 0xff));


AndroidManifest Setting:


<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />