Search code examples
androidandroid-arrayadapterandroid-spinnerandroid-4.0-ice-cream-sandwichandroid-sdk-2.3

App doesn't work on 4.0.3 but it works on 2.3.3


I write an app and it works properly on android 2.3.3 , but it doesn't work on android 4.0.3.

I specify minsdk="10" and targetsdk="15" in my AndroidManifest file.

I am using .net web service in my app and I'm getting error on this page.

myspinner = (Spinner) findViewById(R.id.ihtiyacsec);
        ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item, SektorList);
        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        myspinner.setAdapter(adapter);

SektorList is null.

I'm using ksoap2 for access my web service.

Here is my function

SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
        envelope.bodyOut=request;
        envelope.dotNet = true;     
        envelope.setOutputSoapObject(request);
        HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
        androidHttpTransport.debug = true;

       try {

       androidHttpTransport.call(SOAP_ACTION, envelope);
       SoapObject response = (SoapObject) envelope.getResponse();
       SektorList = new String[response.getPropertyCount()];

      for(int i=0;i<response.getPropertyCount();i++){          
               SektorList[i] = response.getPropertyAsString(i).toString();     
      }      
} 
        catch (Exception e) {           
            e.printStackTrace();
       }

When I debug the project , androidHttpTransport.call(SOAP_ACTION, envelope) is not work and compiler jump to catch block.

I know my soap action is true (same codes work in 2.3.3).

I dont know what is the problem ?


Solution

  • Thats a very common problem. As of Android HC+ you aren't allowed to perform heavy network operations in your main UI thread. To solve this problem you could: remove the "targetsdk" tag from your manifest(not recommended) or just use an asynctask for your network operation.