应用程序无法在4.0.3工作,但它适用于2.3.3 [英] App doesn't work on 4.0.3 but it works on 2.3.3

查看:277
本文介绍了应用程序无法在4.0.3工作,但它适用于2.3.3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写一个应用程序,并能正常工作,在Android 2.3.3,但它并没有在Android 4.0.3工作。

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

我指定minsdk =10和targetsdk =15在我AndroidManifest文件。

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

我在我的应用程序使用.NET Web服务,我在此页面上收到错误。

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为null。

SektorList is null.

我使用kso​​ap2访问我的web服务。

I'm using ksoap2 for access my web service.

下面是我的功能

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();
       }

当我调试项目,androidHttpTransport.call(SOAP_ACTION,信封)没有工作,编译器跳转到catch块。

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

我知道我的SOAP动作是真实的(在同2.3.3 codeS工作)。

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

我不知道是什么问题?

I dont know what is the problem ?

推荐答案

那是一个非常普遍的问题。由于Android的HC +的你不能在你的主UI线程执行繁重的网络操作。为了解决这个问题,你可以:从你的清单中删除了targetsdk标签(不推荐),或只是使用AsyncTask的为您的网络操作。

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.

这篇关于应用程序无法在4.0.3工作,但它适用于2.3.3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆