RulTech - Strict Mode on Android 2.2

MAR

29

2584

Strict Mode on Android 2.2

Set the Android Manifest to something like this.

<uses-sdkandroid:minSdkVersion="8" 
          android:targetSdkVersion="16"
          android:maxSdkVersion="16"/>

Use the Code below in onCreate Method as shown

@Override
protected void onCreate() 
{
       int SDK_INT = android.os.Build.VERSION.SDK_INT;

        if (SDK_INT>8)
           {
                    StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
                    StrictMode.setThreadPolicy(policy); 

           }
       super.onCreate();
    
}
Note: Disable the warning as you are already checking which version of the Android is going to use this code.

This Code will be activated if the Android version is higher than Android 2.2

Add Comment

COMPANY INTRO

RulTech is a provider of total IT support & services viz. Installation, Configuration, Maintenance, Troubleshooting, Mobile development (iPhone & Android applications), Web Development (Java, dot net, PHP, Word Press, Joomla open source), Content writing & Data Analysis.

BLOG POSTS