Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9229999
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T05:42:47+00:00 2026-06-18T05:42:47+00:00

I’m trying to get some information from a thread and i dont know how.

  • 0

I’m trying to get some information from a thread and i dont know how.
I never used threads and my question is about that.

I have one activity what uses a webservice with one thread. After this i want to do some action if the result is true and do other if the result is false.

I cant modify local or global variables in the thread so i dont know how to do. I don’t want to throw the intent in the thread.

Is there any way to return this result? thanks

This is my activity code:

public class RegisterActivity extends Activity {

//Constantes para la invocacion del web service
private static final String NAMESPACE = "http://webservice.proyecto";
private static String URL="http://192.168.1.34:8080/BDManejador/services/conexion?wsdl";
private static final String METHOD_NAME = "nuevo_usuario";
private static final String SOAP_ACTION ="http://ws.webapp.ejemplo/nuevo_usuario";  

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_register);
}

public void goMainMenu (View v) {

    final EditText email = (EditText)findViewById(R.id.user);
    final EditText password = (EditText)findViewById(R.id.pass);
    EditText repeat_password = (EditText)findViewById(R.id.rpass);

    // COMPROBAR EMAIL VALIDO
    if((email.getText().toString().length() == 0) || (!email.getText().toString().contains("@")) ||(!email.getText().toString().contains("."))) {
        Toast toast= Toast.makeText(getApplicationContext(), "DIRECCIÓN DE CORREO ELECTRÓNICO NO VÁLIDA", Toast.LENGTH_LONG);
        toast.show();
    }
    else {

        // COMPROBAR CONTRASEÑA REPETIDA IGUAL
        if((password.getText().toString().compareTo(repeat_password.getText().toString()) == 0) && (password.getText().toString().length()!=0)) {

            // USAMOS EL WEBSERVICE

            Thread networkThread = new Thread() {
                @Override
                public void run() {
                  try {
                     SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);          
                     request.addProperty("email", email.getText().toString());
                     request.addProperty("pass", password.getText().toString());

                     SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
                     envelope.setOutputSoapObject(request);

                     HttpTransportSE ht = new HttpTransportSE(URL);
                     ht.call(SOAP_ACTION, envelope);
                     final  SoapPrimitive response = (SoapPrimitive)envelope.getResponse();
                     final boolean str = Boolean.parseBoolean(response.toString());
                     if (str) {
                         Log.v("MYAPP",  "INSERTADO");
                     }
                     else
                         Log.v("MYAPP",  "NO INSERTADO");
                  } 
                 catch (Exception e) {
                     e.printStackTrace();
                 }
                }
            };
            networkThread.start();

            //ESPERAR QUE TERMINE LA OPERACION
            try {
                networkThread.join();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }               

            //LANZAR LA NUEVA ACTIVIDAD
            Intent intent = new Intent(RegisterActivity.this, MenuActivity.class);
            startActivity(intent);

        }
        else {
            Toast toast= Toast.makeText(getApplicationContext(), "LAS CONTRASEÑAS DEBEN SER IGUALES", Toast.LENGTH_LONG);
            toast.show();
        }
    }

}

}

So I want to throw my intent when variable boolean str is true.

Someone can help?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T05:42:48+00:00Added an answer on June 18, 2026 at 5:42 am

    UI cannot be manipulated on some other non-UI threads.

    I think you should go with AsyncTask interface.

    See this reference :

    Painless threading

    For such long and time consuming background tasks AsyncTask is a best choice. By which you can easily execute things in background and on completion of job you can update UI from the onPostExecute method.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I am trying to find ID3V2 tags from MP3 file using jid3lib in Java.
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I know there's a lot of other questions out there that deal with this
I don't have much knowledge about the IPv6 protocol, so sorry if the question
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to create an if statement in PHP that prevents a single post
I have a view passing on information from a database: def serve_article(request, id): served_article
Basically, what I'm trying to create is a page of div tags, each has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.