multithreading - How to pass values and get response from a Runnable Thread in Android with exit function? -
I have implemented a login form in Android, it was advised that I get data from the webservice for logon authentication Runnable threads should be used, as suggested by using runnable threads for the Android network function. I did the same, but there is a function that would be asked to execute the thread, if the login has been certified, then I should give the value to the thread eg. 1 and on that basis I will perform some functions to perform the next task. I have seen many solutions like applying a class and passing parameters, but none of them work for my requirement. I am writing down the steps to understand my problem further.
1- I want to pass two parameters for runline thread login accent function.
2- I want to get the return value from the thread function, in my main thread.
3- After the end of my child's thread, I want to call some other function of my original thread (main thread), because I want to do the next thing in it, like opening the profile screen.
I have used the global variable "loginResponse" in my code, but it is not helping.
I'm writing my code here, I am new to Android, please forgive me. / P>
try {new thread (new runnable) (public void run () {Looper.prepare (); webserviceCall wb = new WebserviceCall (); loginResponse = wb.LoginWarden ("LoginWarden");} }).Start(); // Just Toast To test getApplicationContext, "msg:" + display display + ", toast. LNNGHHORART) Show (); If (loginResponse == "1") {intent to myIntent = new (getBaseContext), violation Reeporter.class); MyIntent.setFlags (Intent.FLAG_ACTIVITY_CLEAR_TOP); StartActivity (myIntent); End(); } Else {toast.makeText (getApplicationContext), "Username or password is not valid.", Toast .LENGTH_SHORT). Show (); }} Hold (Exception Pre) {Toast. MakeApplicationContext, "Error:" + East .getMessage (), Toast .LENGTH_SHORT). Show (); } Use this asynctask for this problem that it needs all ..
Comments
Post a Comment