android-service的返回类型是什么意思?

时间:2016-02-24 19:19:01

标签: android

在android中我实现了AlarmService如下:

public class AlarmService extends Service
{
    Alarm alarm = new Alarm();
    public void onCreate()
    {
        super.onCreate();
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId)
    {
        alarm.SetAlarm(this);
        return START_STICKY;
    }


    @Override
    public IBinder onBind(Intent intent)
    {
        return null;
    }
}

该方法返回标志START_STICKY,我不明白这意味着什么。来自documentation

.....
int START_STICKY    Constant to return from onStartCommand(Intent, int, int): if this service's process is killed while it is started (after returning from onStartCommand(Intent, int, int)), then leave it in the started state but don't retain this delivered intent.
int START_STICKY_COMPATIBILITY  Constant to return from onStartCommand(Intent, int, int): compatibility version of START_STICKY that does not guarantee that onStartCommand(Intent, int, int) will be called again after being killed.

说真的,我可以阅读英文,但我绝对不知道文档中所有这些不同的返回类型是什么意思。也许有关于文档的文档?什么能真正解释Android初学者的内容......?

0 个答案:

没有答案