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
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() {
Yes, that's pretty close to what I had in mind - assuming that the
handler is created on the UI thread, such as inside the service's
onCreate().
And I would marshal the message string, not the Toast object, so you
don't even have to instantiate Toast objects in the worker thread.
But the
Hi,
No unfortunately that didn't work.
Thanks for the idea though. I think I'll use a notification instead (as it
appears I probably should be).
Cheers,
Julius.
On 2/03/2011, at 8:56 AM, Kostya Vasilyev wrote:
Yes, that's pretty close to what I had in mind - assuming that the handler is
Hi,
I have an IntentService from which I am showing a Toast using:
Toast.makeText(this, errorMessage.toString(),
Toast.LENGTH_SHORT).show();
For some reason it's not disappearing. Just wondering if anyone has seen this
before or knows what I'm doing wrong. I'm sure it's just
On Mon, Feb 28, 2011 at 8:53 PM, Julius Spencer jul...@msa.co.nz 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?
-
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 jul...@msa.co.nz wrote:
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
8 matches
Mail list logo