Question

I have developed a simple client server android application. I have created the application to work on all versions of android. So I have given this code on androidmanifest.xml file.

<uses-sdk android:minSdkVersion="10" 
    android:targetSdkVersion="16"/>

For establishing connectivity I have used this jar file (ksoap2-android-assembly-2.5.8-jar-with-dependencies) in my application. The problem now is that the application works fine and error free on android versions upto gingerbread. But when I try to run it on versions above that, the app does not work, not even tries to send data to the server, whereas on gingerbread and below, it client and server communication works fine. What is the possible problem for this error. Is it because of the jar file which I'm using. For establishing the client server communication I have imported the following in my project.

import org.ksoap2.SoapEnvelope;
import org.ksoap2.SoapFault;
import org.ksoap2.serialization.PropertyInfo;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;
Was it helpful?

Solution

Use of AsyncTask in my application solved it. Or else you can use the following code in your mainactivity below setcontentview

if (android.os.Build.VERSION.SDK_INT > 9) {
        StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
        StrictMode.setThreadPolicy(policy);
    }

This is not a recommended way of solving this kind of errors in android, but at times when you are needy, you can use it. But I would not recommend doing this.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top