gohan0189
28/05/12, 21:13:16
porque no puedo poner un toast aqui (lo que esta en rojo):
Thread thread = new Thread(){
@Override
public void run()
{
while(realizado==false)
{
try{
SoapObject solicitud = new SoapObject(namespace, Metodo);
solicitud.addProperty("folioPoliza", edtxtpoliza.getText().toString());
solicitud.addProperty("inciso", edtxtinciso.getText().toString());
SoapSerializationEnvelope envoltorio = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envoltorio.dotNet = true;
envoltorio.setOutputSoapObject(solicitud);
HttpTransportSE transporte = new HttpTransportSE(url);
try {
transporte.call(accionSoap, envoltorio);
Object result = (Object)envoltorio.getResponse();
JSONString=result.toString();
DecoderConfiguration config = new DecoderConfiguration(false, AutoValueObject.class);
auto = (AutoValueObject)deserializeJsonResponse(config, JSONString);
realizado=true;
}
catch (Exception e)
{
realizado=true;
x=false;
progressDialog.dismiss();
// Toast toast = Toast.makeText(getApplicationContext(), "No se pudo comunicar con el servidor", Toast.LENGTH_SHORT);
// toast.show();
}
this.sleep(5000);
} catch (InterruptedException ex) {
Toast toast = Toast.makeText(getApplicationContext(), "Proceso terminado", Toast.LENGTH_SHORT);
toast.show();
}
}
handler.sendEmptyMessage(0);
}
};
final Handler handler = new Handler(){
@Override
public void handleMessage(Message msg) {
edtxt1.setText((xxxxx).toString());
edtxt2.setText((xxxxx2).toString());
edtxt3.setText((xxxx3).toString());
edtxt4.setText((xxxx4).toString());
edtxt5.setText((xxxx5).toString());
edtxt6.setText((xxxx6).toString());
relativelayout.setVisibility(View.VISIBLE);
btobtener.setVisibility(View.GONE);
progressDialog.dismiss();
}si pongo el toast que esta en rojo me sale el siguiente error:
FATAL EXCEPTION: Thread-10
java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
at android.os.Handler.<init>(Handler.java:121)
at android.widget.Toast.<init>(Toast.java:68)
at android.widget.Toast.makeText(Toast.java:231)
at SAO.AutoHelp.Registro1$5.run(Registro1.java:182)
Activity SAO.AutoHelp.Registro1 has leaked IntentReceiver SAO.AutoHelp.Registro1$1@49dbb538 that was originally registered here. Are you missing a call to unregisterReceiver()?
android.app.IntentReceiverLeaked: Activity SAO.AutoHelp.Registro1 has leaked IntentReceiver SAO.AutoHelp.Registro1$1@49dbb538 that was originally registered here. Are you missing a call to unregisterReceiver()?
at android.app.ActivityThread$PackageInfo$ReceiverDis patcher.<init>(ActivityThread.java:940)
at android.app.ActivityThread$PackageInfo.getReceiver Dispatcher(ActivityThread.java:735)
android.app.ContextImpl.registerReceiverInternal(C ontextImpl.java:799)
android.app.ContextImpl.registerReceiver(ContextIm pl.java:786)
android.app.ContextImpl.registerReceiver(ContextIm pl.java:780)
android.content.ContextWrapper.registerReceiver(Co ntextWrapper.java:318)
SAO.AutoHelp.Registro1.onCreate(Registro1.java:76)
android.app.Instrumentation.callActivityOnCreate(I nstrumentation.java:1047)
android.app.ActivityThread.performLaunchActivity(A ctivityThread.java:2633)
android.app.ActivityThread.handleLaunchActivity(Ac tivityThread.java:2685)
android.app.ActivityThread.access$2300(ActivityThr ead.java:126)
android.app.ActivityThread$H.handleMessage(Activit yThread.java:2038)
android.os.Handler.dispatchMessage(Handler.java:99 )
android.os.Looper.loop(Looper.java:123)
android.app.ActivityThread.main(ActivityThread.jav a:4633)
java.lang.reflect.Method.invokeNative(Native Method)
java.lang.reflect.Method.invoke(Method.java:521)
com.android.internal.os.ZygoteInit$MethodAndArgsCa ller.run(ZygoteInit.java:858)
com.android.internal.os.ZygoteInit.main(ZygoteInit .java:616)
dalvik.system.NativeStart.main(Native Method)
Thread thread = new Thread(){
@Override
public void run()
{
while(realizado==false)
{
try{
SoapObject solicitud = new SoapObject(namespace, Metodo);
solicitud.addProperty("folioPoliza", edtxtpoliza.getText().toString());
solicitud.addProperty("inciso", edtxtinciso.getText().toString());
SoapSerializationEnvelope envoltorio = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envoltorio.dotNet = true;
envoltorio.setOutputSoapObject(solicitud);
HttpTransportSE transporte = new HttpTransportSE(url);
try {
transporte.call(accionSoap, envoltorio);
Object result = (Object)envoltorio.getResponse();
JSONString=result.toString();
DecoderConfiguration config = new DecoderConfiguration(false, AutoValueObject.class);
auto = (AutoValueObject)deserializeJsonResponse(config, JSONString);
realizado=true;
}
catch (Exception e)
{
realizado=true;
x=false;
progressDialog.dismiss();
// Toast toast = Toast.makeText(getApplicationContext(), "No se pudo comunicar con el servidor", Toast.LENGTH_SHORT);
// toast.show();
}
this.sleep(5000);
} catch (InterruptedException ex) {
Toast toast = Toast.makeText(getApplicationContext(), "Proceso terminado", Toast.LENGTH_SHORT);
toast.show();
}
}
handler.sendEmptyMessage(0);
}
};
final Handler handler = new Handler(){
@Override
public void handleMessage(Message msg) {
edtxt1.setText((xxxxx).toString());
edtxt2.setText((xxxxx2).toString());
edtxt3.setText((xxxx3).toString());
edtxt4.setText((xxxx4).toString());
edtxt5.setText((xxxx5).toString());
edtxt6.setText((xxxx6).toString());
relativelayout.setVisibility(View.VISIBLE);
btobtener.setVisibility(View.GONE);
progressDialog.dismiss();
}si pongo el toast que esta en rojo me sale el siguiente error:
FATAL EXCEPTION: Thread-10
java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
at android.os.Handler.<init>(Handler.java:121)
at android.widget.Toast.<init>(Toast.java:68)
at android.widget.Toast.makeText(Toast.java:231)
at SAO.AutoHelp.Registro1$5.run(Registro1.java:182)
Activity SAO.AutoHelp.Registro1 has leaked IntentReceiver SAO.AutoHelp.Registro1$1@49dbb538 that was originally registered here. Are you missing a call to unregisterReceiver()?
android.app.IntentReceiverLeaked: Activity SAO.AutoHelp.Registro1 has leaked IntentReceiver SAO.AutoHelp.Registro1$1@49dbb538 that was originally registered here. Are you missing a call to unregisterReceiver()?
at android.app.ActivityThread$PackageInfo$ReceiverDis patcher.<init>(ActivityThread.java:940)
at android.app.ActivityThread$PackageInfo.getReceiver Dispatcher(ActivityThread.java:735)
android.app.ContextImpl.registerReceiverInternal(C ontextImpl.java:799)
android.app.ContextImpl.registerReceiver(ContextIm pl.java:786)
android.app.ContextImpl.registerReceiver(ContextIm pl.java:780)
android.content.ContextWrapper.registerReceiver(Co ntextWrapper.java:318)
SAO.AutoHelp.Registro1.onCreate(Registro1.java:76)
android.app.Instrumentation.callActivityOnCreate(I nstrumentation.java:1047)
android.app.ActivityThread.performLaunchActivity(A ctivityThread.java:2633)
android.app.ActivityThread.handleLaunchActivity(Ac tivityThread.java:2685)
android.app.ActivityThread.access$2300(ActivityThr ead.java:126)
android.app.ActivityThread$H.handleMessage(Activit yThread.java:2038)
android.os.Handler.dispatchMessage(Handler.java:99 )
android.os.Looper.loop(Looper.java:123)
android.app.ActivityThread.main(ActivityThread.jav a:4633)
java.lang.reflect.Method.invokeNative(Native Method)
java.lang.reflect.Method.invoke(Method.java:521)
com.android.internal.os.ZygoteInit$MethodAndArgsCa ller.run(ZygoteInit.java:858)
com.android.internal.os.ZygoteInit.main(ZygoteInit .java:616)
dalvik.system.NativeStart.main(Native Method)