Win a copy of Pro Spring MVC with WebFlux: Web Development in Spring Framework 5 and Spring Boot 2 this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Bear Bibeault
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh

How to pass parameters from inside handler to an Asynctask?

 
Ranch Hand
Posts: 234
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, my Java fails me again

I need to pass some parameters from my MainActivity to an asynctask using a handler, so I can start and stop the process anytime.

The parameters (this, loginstatus, result) in the asynctask are used to display the results in the UI ( the TextViews in the XML).

Problem: ( see pic)




Following is my MainActivity that calls the asynctask:




And this is the Asynctask:


AAAAAAAAAAAAAAAAAAAAAAAAAAAAA.jpg
[Thumbnail for AAAAAAAAAAAAAAAAAAAAAAAAAAAAA.jpg]
 
Ranch Hand
Posts: 314
2
Android VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there,

I haven't really used Android handler's before, but from what I have read handlers can be used to send messages to other objects and messages can hold data bundles. So maybe you could add your data to a bundle, add the bundle to the message, and then use the handler to send the message to the AsyncTask. It should work in theory, but having never used handlers I am not sure.

Darryl
 
Ranch Hand
Posts: 536
10
Android Open BSD Slackware
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Darryl A. J. Staflund wrote:Hi there,

I haven't really used Android handler's before, but from what I have read handlers can be used to send messages to other objects and messages can hold data bundles.  So maybe you could add your data to a bundle, add the bundle to the message, and then use the handler to send the message to the AsyncTask.  It should work in theory, but having never used handlers I am not sure.

Darryl



this is a great documentation, for the curious http://codetheory.in/android-handlers-runnables-loopers-messagequeue-handlerthread/
 
I am not young enough to know everything. - Oscar Wilde This tiny ad thinks it knows more than Oscar:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic