1

我正在使用这种代码

private static String SOAP_ACTION = "http://schemas.xmlsoap.org/soap/http";

    private static String NAMESPACE = "http://schemas.xmlsoap.org/soap/encoding/";
    private static String METHOD_NAME = "something";

    private static String URL = "http://server/file.php?wsdl";
parameters.addProperty("SubMSISDN", msisdn);
                            parameters.addProperty("AppID", 2);
request.addProperty(METHOD_NAME, parameters);
                            SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
                            envelope.setOutputSoapObject(request);
                            HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
                            try{
                                androidHttpTransport.call(SOAP_ACTION, envelope);
                            }catch (Exception e) {
                                // TODO: handle exception
                                e.printStackTrace();
                            }
                            try{ 
                            result = (SoapObject) envelope.bodyIn;
                            }catch(NullPointerException e ){
                                e.printStackTrace();
                                Toast.makeText(getApplicationContext(), "Please check your internet connection", Toast.LENGTH_LONG).show();
                            }
                            if(result != null){
do rest of work here
}

这是错误日志

12-13 16:24:16.519: E/AndroidRuntime(14087): FATAL EXCEPTION: main
12-13 16:24:16.519: E/AndroidRuntime(14087): java.lang.NullPointerException
12-13 16:24:16.519: E/AndroidRuntime(14087):    at android.app.Instrumentation.execStartActivity(Instrumentation.java:1374)
12-13 16:24:16.519: E/AndroidRuntime(14087):    at android.app.Activity.startActivityForResult(Activity.java:2827)
12-13 16:24:16.519: E/AndroidRuntime(14087):    at android.app.Activity.startActivity(Activity.java:2933)
12-13 16:24:16.519: E/AndroidRuntime(14087):    at com.syntecx.selfcare.BalanceHis$1.onPostExecute(BalanceHis.java:195)
12-13 16:24:16.519: E/AndroidRuntime(14087):    at com.syntecx.selfcare.BalanceHis$1.onPostExecute(BalanceHis.java:1)
12-13 16:24:16.519: E/AndroidRuntime(14087):    at android.os.AsyncTask.finish(AsyncTask.java:417)
12-13 16:24:16.519: E/AndroidRuntime(14087):    at android.os.AsyncTask.access$300(AsyncTask.java:127)
12-13 16:24:16.519: E/AndroidRuntime(14087):    at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:429)
12-13 16:24:16.519: E/AndroidRuntime(14087):    at android.os.Handler.dispatchMessage(Handler.java:99)
12-13 16:24:16.519: E/AndroidRuntime(14087):    at android.os.Looper.loop(Looper.java:123)
12-13 16:24:16.519: E/AndroidRuntime(14087):    at android.app.ActivityThread.main(ActivityThread.java:3687)
12-13 16:24:16.519: E/AndroidRuntime(14087):    at java.lang.reflect.Method.invokeNative(Native Method)
12-13 16:24:16.519: E/AndroidRuntime(14087):    at java.lang.reflect.Method.invoke(Method.java:507)
12-13 16:24:16.519: E/AndroidRuntime(14087):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
12-13 16:24:16.519: E/AndroidRuntime(14087):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
12-13 16:24:16.519: E/AndroidRuntime(14087):    at dalvik.system.NativeStart.main(Native Method)

当我使用 wifi 时它工作正常,但在 gprs 上的某些设备中,应用程序崩溃并在我调试应用程序时强制关闭上面提到的日志创建显示问题

4

0 回答 0