Re: [android-developers] pass parameters between threads

2013-01-24 Thread Piren
I came to the same conclusion as droidDev due to this:
 IteratorMapString, String iterator = response.iterator(); 

If 'response' isnt a class variable, that would not compile.  Also, in his 
second comment he pretty much confirmed that was the case. I dont think he 
meant to say that by omitting the local  deceleration  it became a member 
variable, rather that because he made the second deceleration, it became 
local (which he didnt know would happen, since he needs some studying on 
Scopes :-P )

On Wednesday, January 23, 2013 6:26:00 PM UTC-8, Lew wrote:

 droidDev wrote:

 You forgot to attribute the quote there, sport.
 Lew said:

 .. What you said there doesn't make sense. A variable has to be 
 explicitly declared as a class or instance member; it doesn't just 
 magically appear when you remove a local variable.

 I think what John was describing does make sense. He had inadvertently 
 created a new response var in an inner scope, thereby effectively masking 
 out his pre-existing instance var of the same name; therefore the response 
 data was being discarded each time the inner scope was exited.

 How do you know that? His code showed nothing like that. There was no 
 instance variable, 
 or even class definition shown. He referred to a 'type declaration  
 MapString, String' but 
 nothing was shown declared to be that type. The only place that appeared 
 was in a generic
 type argument, but removing that would not un-shadow (mask is not a Java 
 term) an instance
 variable.

 Evidence?

  John Merlino wrote:

 I have a thread to make a web service request. And then I get the data
 and store it in response variable. Now I need to add items to the map
 on the main thread, but how do i get the response data back in the
 main thread. Here is what I have:

 private void processHistory(final String authkey, final String unitId)
 {
 new Thread(){
 public void run(){
 ListMapString, String response =
 WebService.getHistoryData(today,unitId,authkey);


 myHandler.post(myRunnable);

 }
 }.start();
 }

 final Runnable myRunnable = new Runnable() {
   public void run() {

 IteratorMapString, String iterator = 
 response.iterator();

 while(iterator.hasNext()){
 MapString, String item = 
 iterator.next();

 mMap.addMarker(new 
 MarkerOptions()
 .position(new
 LatLng(Double.parseDouble(item.get(latitude)),
 Double.parseDouble(item.get(longitude
 .title(item.get(address)));
 }

   }
};


 -- 
 Lew
  


-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] pass parameters between threads

2013-01-23 Thread Piren
Yeah i was thinking the same thing. 

But, how come no one asks him why he wants to get the response data back 
in the main thread  ? It seems like he believes he needs to pass stuff 
around so other threads will have access to them (i dont see any UI related 
calls that would require them to be run on the UI thread).  He needs to do 
more learning on Scopes and Java Threads than info on ASyncTasks.


On Wednesday, January 23, 2013 6:24:30 AM UTC+2, droidDev wrote:

 .. What you said there doesn't make sense. A variable has to be 
 explicitly declared as a class or instance member; it doesn't just 
 magically appear when you remove a local variable.

 I think what John was describing does make sense. He had inadvertently 
 created a new response var in an inner scope, thereby effectively masking 
 out his pre-existing instance var of the same name; therefore the response 
 data was being discarded each time the inner scope was exited.
  On Jan 8, 2013 6:29 PM, John Merlino stoi...@aol.com javascript: 
 wrote:

 I have a thread to make a web service request. And then I get the data
 and store it in response variable. Now I need to add items to the map
 on the main thread, but how do i get the response data back in the
 main thread. Here is what I have:

 private void processHistory(final String authkey, final String unitId)
 {
 new Thread(){
 public void run(){
 ListMapString, String response =
 WebService.getHistoryData(today,unitId,authkey);


 myHandler.post(myRunnable);

 }
 }.start();
 }

 final Runnable myRunnable = new Runnable() {
   public void run() {

 IteratorMapString, String iterator = 
 response.iterator();

 while(iterator.hasNext()){
 MapString, String item = 
 iterator.next();

 mMap.addMarker(new MarkerOptions()
 .position(new
 LatLng(Double.parseDouble(item.get(latitude)),
 Double.parseDouble(item.get(longitude
 .title(item.get(address)));
 }

   }
};

 --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to 
 android-d...@googlegroups.comjavascript:
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.com javascript:
 For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en



-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] pass parameters between threads

2013-01-23 Thread Lew
droidDev wrote:

You forgot to attribute the quote there, sport.
Lew said:

 .. What you said there doesn't make sense. A variable has to be 
 explicitly declared as a class or instance member; it doesn't just 
 magically appear when you remove a local variable.

 I think what John was describing does make sense. He had inadvertently 
 created a new response var in an inner scope, thereby effectively masking 
 out his pre-existing instance var of the same name; therefore the response 
 data was being discarded each time the inner scope was exited.

How do you know that? His code showed nothing like that. There was no 
instance variable, 
or even class definition shown. He referred to a 'type declaration  
MapString, String' but 
nothing was shown declared to be that type. The only place that appeared 
was in a generic
type argument, but removing that would not un-shadow (mask is not a Java 
term) an instance
variable.

Evidence?

  John Merlino wrote:

 I have a thread to make a web service request. And then I get the data
 and store it in response variable. Now I need to add items to the map
 on the main thread, but how do i get the response data back in the
 main thread. Here is what I have:

 private void processHistory(final String authkey, final String unitId)
 {
 new Thread(){
 public void run(){
 ListMapString, String response =
 WebService.getHistoryData(today,unitId,authkey);


 myHandler.post(myRunnable);

 }
 }.start();
 }

 final Runnable myRunnable = new Runnable() {
   public void run() {

 IteratorMapString, String iterator = 
 response.iterator();

 while(iterator.hasNext()){
 MapString, String item = 
 iterator.next();

 mMap.addMarker(new MarkerOptions()
 .position(new
 LatLng(Double.parseDouble(item.get(latitude)),
 Double.parseDouble(item.get(longitude
 .title(item.get(address)));
 }

   }
};


-- 
Lew
 

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] pass parameters between threads

2013-01-22 Thread droid dev
.. What you said there doesn't make sense. A variable has to be explicitly
declared as a class or instance member; it doesn't just magically appear
when you remove a local variable.

I think what John was describing does make sense. He had inadvertently
created a new response var in an inner scope, thereby effectively masking
out his pre-existing instance var of the same name; therefore the response
data was being discarded each time the inner scope was exited.
 On Jan 8, 2013 6:29 PM, John Merlino stoici...@aol.com wrote:

 I have a thread to make a web service request. And then I get the data
 and store it in response variable. Now I need to add items to the map
 on the main thread, but how do i get the response data back in the
 main thread. Here is what I have:

 private void processHistory(final String authkey, final String unitId)
 {
 new Thread(){
 public void run(){
 ListMapString, String response =
 WebService.getHistoryData(today,unitId,authkey);


 myHandler.post(myRunnable);

 }
 }.start();
 }

 final Runnable myRunnable = new Runnable() {
   public void run() {

 IteratorMapString, String iterator =
 response.iterator();

 while(iterator.hasNext()){
 MapString, String item =
 iterator.next();

 mMap.addMarker(new MarkerOptions()
 .position(new
 LatLng(Double.parseDouble(item.get(latitude)),
 Double.parseDouble(item.get(longitude
 .title(item.get(address)));
 }

   }
};

 --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-developers@googlegroups.com
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en


-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] pass parameters between threads

2013-01-08 Thread TreKing
On Tue, Jan 8, 2013 at 5:27 PM, John Merlino stoici...@aol.com wrote:

 I have a thread to make a web service request. And then I get the data and
 store it in response variable. Now I need to add items to the map on the
 main thread, but how do i get the response data back in the main thread.


Use AsyncTask.

-
TreKing http://sites.google.com/site/rezmobileapps/treking - Chicago
transit tracking app for Android-powered devices

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en