有没高手知道,如果不设置service 的onStartCommand返回值,使用默认的
return super.onStartCommand(intent, flags, startId)
service被系统kill后是什么状态?另外:如果设置返回值 START_STICKY ,是否自动重启后会执行onstartcommand方法?
      如果设置返回值 START_NOT_STICKY,被系统杀死后,我在AlarmManager的setRepeating(pendingIntent=PendingIntent.getService(context, 0, intent,0);),service还会定时执行吗?急急急~~~

解决方案 »

  1.   

    The return value indicates what semantics the system should use for the service's current started state. It may be one of the constants associated with the START_CONTINUATION_MASK bits.
    这句话就是启动服务的状态,
    状态值在START_CONTINUATION_MASK里面
    START_CONTINUATION_MASK  :如果是被killed掉,怎么继续这个服务
    START_FLAG_REDELIVERY    
    START_FLAG_RETRY等 
      

  2.   

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {        return super.onStartCommand(intent, flags, startId);
    }
    这样,service被系统killed掉后,会重启吗?如果重启会执行onStartCommand吗?
      

  3.   


    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {  return super.onStartCommand(intent, flags, startId);
    }
    这样,service被系统killed掉后,会重启吗?如果重启会执行onStartCommand吗?
      

  4.   

    START_STICKY是粘滞性的,而START_NOT_STICKY是非粘滞性的,如果是START_NOT_STICKY,Service被系统杀死之后,如果存在未处理的pending intent,那么Service会重新启动,而START_STICKY,无论有无未处理的pending intent,Service都会在被杀死后重新启动