PROBLEMA PARA CONSUMIR WEBSERVICES ASMX CON KSOAP ANDROID STUDIO

Para dar las gracias debes entrar o registrarte en el foro

Recién llegado
Recién llegado
Mensajes: 2 Agradecido: 0
13 Abr 2016, 01:57# 1

Buenas tardes amigos...

Estoy desarrollando una aplicacion la cual tengo que consumir webservices asmx... el cual el metodo es generar un login de inicio de sesion.. ya implemente la class AsyncTask el cual uso el metodo de doInBackground para ejecutar todo mi proceso del login.. solo que al momento de ingresar mi usuario y password y le doy clik en ingresar.... en la consola del android studio me manda este error

Error: Can't create handler inside thread that has not called Looper.prepare()

Y ya no hace nada se queda pasmada mi aplicacion en ese punto... segun eso es por que no esta llamando a llamar la clase thread... ya trate de implementar pero no funciona.. no se si me puedan ayudar a decirme como arreglar este problema... adjunto codigo... les pondre aqui lo que me marca la consola.

04-12 19:25:37.470 1663-1663/com.example.onc_lap.oncontrolmobile D/dalvikvm: VFY: replacing opcode 0x72 at 0x0002
04-12 19:25:37.470 1663-1663/com.example.onc_lap.oncontrolmobile I/dalvikvm: Could not find method android.view.Window$Callback.onWindowStartingActionMode, referenced from method android.support.v7.view.WindowCallbackWrapper.onWindowStartingActionMode
04-12 19:25:37.470 1663-1663/com.example.onc_lap.oncontrolmobile W/dalvikvm: VFY: unable to resolve interface method 18824: Landroid/view/Window$Callback;.onWindowStartingActionMode (Landroid/view/ActionMode$Callback;I)Landroid/view/ActionMode;
04-12 19:25:37.470 1663-1663/com.example.onc_lap.oncontrolmobile D/dalvikvm: VFY: replacing opcode 0x72 at 0x0002
04-12 19:25:37.510 1663-1663/com.example.onc_lap.oncontrolmobile I/dalvikvm: Could not find method android.content.res.TypedArray.getChangingConfigurations, referenced from method android.support.v7.widget.TintTypedArray.getChangingConfigurations
04-12 19:25:37.510 1663-1663/com.example.onc_lap.oncontrolmobile W/dalvikvm: VFY: unable to resolve virtual method 421: Landroid/content/res/TypedArray;.getChangingConfigurations ()I
04-12 19:25:37.510 1663-1663/com.example.onc_lap.oncontrolmobile D/dalvikvm: VFY: replacing opcode 0x6e at 0x0002
04-12 19:25:37.510 1663-1663/com.example.onc_lap.oncontrolmobile I/dalvikvm: Could not find method android.content.res.TypedArray.getType, referenced from method android.support.v7.widget.TintTypedArray.getType
04-12 19:25:37.510 1663-1663/com.example.onc_lap.oncontrolmobile W/dalvikvm: VFY: unable to resolve virtual method 443: Landroid/content/res/TypedArray;.getType (I)I
04-12 19:25:37.510 1663-1663/com.example.onc_lap.oncontrolmobile D/dalvikvm: VFY: replacing opcode 0x6e at 0x0002
04-12 19:25:37.550 1663-1663/com.example.onc_lap.oncontrolmobile D/dalvikvm: GC_FOR_ALLOC freed 196K, 11% free 3274K/3664K, paused 6ms, total 11ms
04-12 19:25:37.960 1663-1663/com.example.onc_lap.oncontrolmobile W/EGL_emulation: eglSurfaceAttrib not implemented
04-12 19:25:37.980 1663-1663/com.example.onc_lap.oncontrolmobile D/OpenGLRenderer: Enabling debug mode 0
04-12 19:26:04.250 1663-1663/com.example.onc_lap.oncontrolmobile I/Response: onPreExecute
04-12 19:26:04.290 1663-1663/com.example.onc_lap.oncontrolmobile D/dalvikvm: GC_FOR_ALLOC freed 154K, 10% free 3494K/3844K, paused 13ms, total 15ms
04-12 19:26:04.320 1663-1663/com.example.onc_lap.oncontrolmobile D/dalvikvm: GC_FOR_ALLOC freed 6K, 9% free 3641K/4000K, paused 3ms, total 4ms
04-12 19:26:04.320 1663-1663/com.example.onc_lap.oncontrolmobile I/dalvikvm-heap: Grow heap (frag case) to 5.426MB for 1764372-byte allocation
04-12 19:26:04.340 1663-1673/com.example.onc_lap.oncontrolmobile D/dalvikvm: GC_FOR_ALLOC freed <1K, 7% free 5364K/5724K, paused 18ms, total 18ms
04-12 19:26:04.450 1663-1663/com.example.onc_lap.oncontrolmobile W/EGL_emulation: eglSurfaceAttrib not implemented
04-12 19:26:04.630 1663-2469/com.example.onc_lap.oncontrolmobile E/Response: Error: Can't create handler inside thread that has not called Looper.prepare()


y les pongo el codigo mi activity



package com.example.onc_lap.oncontrolmobile;


import org.ksoap2.SoapEnvelope;
import org.ksoap2.SoapFault;
import org.ksoap2.serialization.PropertyInfo;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapPrimitive;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;

import android.app.ProgressDialog;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.StrictMode;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.View;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;



import java.net.URL;
import java.net.URLConnection;

public class Principal extends AppCompatActivity {

EditText txtusuario;
EditText txtpassword;
private Button btningresar;
private Handler mHandler = new Handler();

private ProgressDialog pDialog;

String TAG = "Response";

public final int dialogo_alert = 0;
public String msje = "";



@Override
protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);
setContentView(R.layout.activity_principal);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);

txtusuario = (EditText) findViewById(R.id.txtusuario);
txtpassword = (EditText) findViewById(R.id.txtpassword);
btningresar = (Button) findViewById(R.id.btningresar);
btningresar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Log.i(TAG, "");
new webserv().execute();

} //fin del click view

});
}



class webserv extends AsyncTask {


public String NAMESPACE = "http://ONControl_MobileWS/";
public String METHOD_NAME = "Login";
public String SOAP_ACTION = "http://ONControl_MobileWS/Login";
public String SOAP_ADDRESS;
private SoapObject request;
private HttpTransportSE transporte;
private SoapSerializationEnvelope envelope;


@Override
protected String doInBackground(String... params) {
Login();
return "Bienvenido";

}


protected void onPreExecute() {

Log.i(TAG, "onPreExecute");

pDialog = new ProgressDialog(Principal.this);
pDialog.setMessage("Iniciando sesion ...");
pDialog.setIndeterminate(false);
pDialog.setMax(10);
pDialog.setCancelable(false);
pDialog.show();
}



protected void onPostExecute(String result) {


super.onPostExecute(result);

mHandler.post(new Runnable() {
@Override
public void run() {

}
});

/* runOnUiThread(new Runnable() {
public void run() {
// runs on UI thread
}
});*/


}


public void Login(){
SOAP_ADDRESS = "http://oncontrol.no-ip.net:9020/ONControl_MobileWS.asmx";
request = new SoapObject(NAMESPACE, METHOD_NAME);
PropertyInfo pi= new PropertyInfo();
envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
transporte = new HttpTransportSE(SOAP_ADDRESS);

request.addProperty("usuario", txtusuario.getText().toString());
request.addProperty("password", txtpassword.getText().toString());

try {
transporte.call(SOAP_ACTION, envelope);

SoapPrimitive resultado_xml =(SoapPrimitive)envelope.getResponse();
String res = resultado_xml.toString();
Principal.this.msje=res;
// mostramos la respuesta en un toast
Toast.makeText(Principal.this.getBaseContext(), res,Toast.LENGTH_SHORT).show();

if(res.equals("Gracias por Iniciar Sesion")){
Principal.this.txtusuario.getText().toString();
Principal.this.txtusuario.setText("");
Principal.this.txtpassword.setText("");
//envia al otro activity
Intent intent=new Intent("android.intent.menu");
startActivity(intent);
finish();
}

} catch (Exception e) {
Log.e(TAG, "Error: " + e.getMessage());
}

}



}

//run
}

Adjuntos
error2.png
error
error2.png (138.21 KiB) Visto 1474 veces
Gracias  
Etiquetado en: