• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

How to pass parameters from inside handler to an Asynctask?

 
Ranch Hand
Posts: 270
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: 552
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/
 
pie. tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic