Hi Lance!

Thanks for the links! Now it's working!
(And I learned something about thread save UI in Android)

Thanks again,
Anton


Lance Nanek wrote:
> The UI is not thread safe and calling related methods from a
> background thread like that run by java.util.Timer can cause trouble.
> There's a good blog post on ways to schedule work on the UI thread or
> communicate back to it here:
> http://android-developers.blogspot.com/2009/05/painless-threading.html
>
> There's also an example of communicating back to the UI thread called
> "Example ProgressDialog with a second thread" on this page:
> http://developer.android.com/intl/fr/guide/topics/ui/dialogs.html
>
> On Oct 31, 4:42 pm, Anton Pirker <an...@ignaz.at> wrote:
>   
>> Hi android guys and girls!
>>
>> I have a really strange problem. I have an activity which displays a map
>> and a marker with the users current location on that maps.
>>
>> Right now my code is something like this: (in onCreate of the activity)
>>
>> 1) display a progress dialog with the text "detecting your location,
>> please wait..."
>>
>> 2) request location updates. (activity implements LocationListener)
>>     locationManager.requestLocationUpdates(provider,
>> (long)Constants.MIN_TIME, (float)Constants.MIN_DISTANCE, this);
>>
>> 3) right after the line above i have following:
>>     timer.schedule(new GetLastLocation(this), 5000);
>>     which means: wait 5 sec and then call GetLastLocation().run()
>>
>>     GetLastLocation looks like this:
>>
>>     class GetLastLocation extends TimerTask {
>>         private SetupActivity parent;
>>         public GetLastLocation(SetupActivity act) {
>>             parent = act;
>>         }
>>         public void run() {
>>             removeDialog(DIALOG_GET_POSITION);
>>             parent.showMessage();
>>         }
>>     }
>>
>>     So if 5 seconds pass by, i dismiss(remove) the dialog i displayed in 1)
>>
>> 4) now i want to show an AlertDialog with the message "could not find
>> your location, taking the last known"
>>     parent.showMessage() looks like this:
>>     public void showMessage() {
>>         Log.e("###", "showMessage 1/2");
>>         showDialog(DIALOG_GET_POSITION);
>>         Log.e("###", "showMessage 2/2");
>>     }
>>
>> and here the first log message "showMessage 1/2" is printed to the log,
>> but not the second one "showMessage 2/2".
>> And there is no exception and nothing that tells me what is wrong...
>>
>> Could someone please help me?
>> Maybe there is a better way to get he location and if no location is
>> delivered show a message!
>>
>> Thankful for every hint,
>> Anton
>>
>> --
>> DI(FH) Anton Pirker
>>
>> ------------------------------
>> cross platform mobile software
>> burggasse 123/53
>> a-1070 wien
>> tel: +43 699 1234 0 456
>> skype: antonpirker
>>
>> http://anton-pirker.at
>>     
>
>   


-- 
DI(FH) Anton Pirker

------------------------------
cross platform mobile software
burggasse 123/53
a-1070 wien
tel: +43 699 1234 0 456
skype: antonpirker

http://anton-pirker.at



-- 
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

Reply via email to