Hi Kostya,
I'm not sure how to access the UI thread from within an IntentService. (If in
an Activity I would use runOnUiThread)
So far I have:
private void showToastOnUIThread(final Toast toast) {
handler.post(new Runnable() {
@Override
public void run() {
toast.show();
}
});
}
The handler object is created in the IntentService. Thank you for the idea.
Regards,
Julius.
On 1/03/2011, at 10:13 PM, Kostya Vasilyev wrote:
> Julius,
>
> You mentioned IntentService, which runs your code on a background thread.
>
> Even though Toast can supposedly be shown from any thread, I'd try changing
> the code so that you show the toast from the UI thread. That's easy to do
> with a Handler and a small Runnable subclass.
>
> -- Kostya
>
> 01.03.2011 10:06, Julius Spencer пишет:
>> Unfortunately that didn't work. In on Destroy() I put in:
>>
>> System.out.println("Duration: "+toastMessage.getDuration());
>> toastMessage.cancel();
>>
>> (where toastMessage was assigned any toastMessage I'd created and shown)
>>
>> and I got:
>> Duration: 0
>>
>> Not sure if that is of any use. I've never had any trouble with Toasts
>> (except not calling show() :) ). I'm a bit stumped.
>>
>> Regards,
>> Julius.
>>
>>
>> On 1/03/2011, at 7:50 PM, Julius Spencer wrote:
>>
>>> Yeah it's definitely being hit just once (I put a break point in).
>>>
>>> I'll try out dismissing it if the IntentService is destroyed.
>>>
>>> Thanks for the replies everyone.
>>>
>>> Regards,
>>> Julius.
>>>
>>>
>>> On 1/03/2011, at 4:15 PM, TreKing wrote:
>>>
>>>> On Mon, Feb 28, 2011 at 8:53 PM, Julius Spencer<[email protected]> wrote:
>>>> I'm sure it's just something I'm not thinking of but I'm stumped...
>>>>
>>>> You're not calling it over and over again are you?
>>>>
>>>> -------------------------------------------------------------------------------------------------
>>>> 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 [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
>
>
> --
> Kostya Vasilyev -- http://kmansoft.wordpress.com
>
> --
> 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
--
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