MAR
29
17744- Written by Pravin Dodia
- Published in Blog Post
- Be the first to comment!
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