hi

put ur code in onstart() instead of oncreate()

becuase ur on create will get call only once through out the life cycle of
service.

hope this will help u




On Tue, Nov 24, 2009 at 2:25 PM, Wei Jian <weijia...@gmail.com> wrote:

> Hello. i wish to use implement Service in my application to display a
> message on the screen. This service should run while my application is
> running. But right now, i just want to test the service function and
> the Service doesn't seem to work well.
>
> In the main java file, i call startService(new Intent
> (this,testing.class));
>
> And the testing.java code is as below.
>
> package com.example.helloandroid;
>
> //import android.app.NotificationManager;
> import android.app.Service;
> import android.content.Intent;
> import android.os.IBinder;
> import android.widget.Toast;
>
> public class testing extends Service{
>
>
>        @Override
>    public void onCreate() {
>                Toast mToast = Toast.makeText(this, R.string.app_name,
>                    Toast.LENGTH_LONG);
>                mToast.show();
>    }
>
>
>        @Override
>        public IBinder onBind(Intent arg0) {
>                // TODO Auto-generated method stub
>                return null;
>        }
>
>
> }
>
>
> Why it isn't displaying the Toast message? Can anyone help please!!!
>
> --
> 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<android-developers%2bunsubscr...@googlegroups.com>
> 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 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