This week's book giveaway is in the Artificial Intelligence and Machine Learning forum.
We're giving away four copies of Zero to AI - A non-technical, hype-free guide to prospering in the AI era and have Nicolò Valigi and Gianluca Mauro on-line!
See this thread for details.
Win a copy of Zero to AI - A non-technical, hype-free guide to prospering in the AI era this week in the Artificial Intelligence and Machine Learning 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

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
  • 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
  • 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: 529
10
Android Open BSD Slackware
  • Mark post as helpful
  • send pies
  • 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/
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic