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 " 
Map<String, 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(){
>>                                 List<Map<String, String>> response =
>> WebService.getHistoryData("today",unitId,authkey);
>>
>>
>>                                 myHandler.post(myRunnable);
>>
>>                         }
>>                 }.start();
>>         }
>>
>>         final Runnable myRunnable = new Runnable() {
>>               public void run() {
>>
>>                                 Iterator<Map<String, String>> iterator = 
>> response.iterator();
>>
>>                                 while(iterator.hasNext()){
>>                                         Map<String, 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 [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to