Re: [android-developers] Re: How to use Toast.makeText in Service

2010-08-11 Thread CaryWang
yes ,I run Activity in the front but I hava run service run in the background.Now I want use Toast.makeText this method show message on the Activity. In Service I don't know get Activity context so Toast.makeText method don't show message to screen. 2010/8/11 Bob Kerns > My guess? I'd guess that

Re: [android-developers] Re: How to use Toast.makeText in Service

2010-08-11 Thread TreKing
On Wed, Aug 11, 2010 at 6:26 AM, Bob Kerns wrote: > But you want the service context, which is just 'this' (i.e. the > service itself). The application context would work too, but generally > you should go with the most specific context available unless you have > a reason otherwise. Using some c

[android-developers] Re: How to use Toast.makeText in Service

2010-08-11 Thread Bob Kerns
My guess? I'd guess that you're expecting it to immediately show up, and you're continuing to do something right afterwards. It will not show up until after you exit from the method. Toast.show() queues up a request to show it, it doesn't actually do anything on the screen itself. (It can't). It'

[android-developers] Re: How to use Toast.makeText in Service

2010-08-11 Thread Bob Kerns
No, it's not either one, it's Application context. But you want the service context, which is just 'this' (i.e. the service itself). The application context would work too, but generally you should go with the most specific context available unless you have a reason otherwise. Using some context (

[android-developers] Re: How to use Toast.makeText in Service

2010-08-11 Thread Sarwar Erfan
On Aug 11, 3:57 pm, CaryWang wrote: > NO,getApplicationContext() is Service Context don't Activity Context. Go to this page: http://developer.android.com/reference/android/widget/Toast.html Under the description of the method makeText, you will find: Parameters context The context to u

Re: [android-developers] Re: How to use Toast.makeText in Service

2010-08-11 Thread CaryWang
I use Toast.makeText(getApplicationContext(), "test", Toast.LENGTH_SHORT).show(); don't display in the Activity.why? 2010/8/11 Sarwar Erfan > Do you wan to display a Toast from a Service? You do not need any > Activy to do so. > A toast can be created and displayed from an Activity or Service. I

[android-developers] Re: How to use Toast.makeText in Service

2010-08-11 Thread Sarwar Erfan
Do you wan to display a Toast from a Service? You do not need any Activy to do so. A toast can be created and displayed from an Activity or Service. If you create a toast notification from a Service, it appears in front of the Activity currently in focus. A Service is indirectly derived from Conte