• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to pass parameters from inside handler to an Asynctask?

 
Ranch Hand
Posts: 271
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: 606
11
Android Python Open BSD VI Editor 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/
 
reply
    Bookmark Topic Watch Topic
  • New Topic