HandleServiceArgs空指针异常~Android服务

HandleServiceArgs空指针异常~Android服务,android,service,nullpointerexception,Android,Service,Nullpointerexception,此程序检测用户是否更改根访问状态。用户定义任何时间段。在此时间段内,它控制rootaccess状态。当我启动服务时,它会给出一个错误。实际上它以前是工作的,但现在不是了。我找不到任何空变量。 我在设备上打开应用程序管理器并查看运行的服务。这项服务上面写着“重新开始” 根访问服务 public class RootAccessService extends Service{ @Override public IBinder onBind(Intent intent) { return n

此程序检测用户是否更改根访问状态。用户定义任何时间段。在此时间段内,它控制rootaccess状态。当我启动服务时,它会给出一个错误。实际上它以前是工作的,但现在不是了。我找不到任何空变量。 我在设备上打开应用程序管理器并查看运行的服务。这项服务上面写着“重新开始”

根访问服务

public class RootAccessService extends Service{

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

@Override
public void onStart(Intent intent,int startId) {

    Bundle b= intent.getExtras();
    if(b != null){

        context = getApplicationContext();
        helper = new SQLiteHelper(context);
        timer = new Timer();
        handler = new Handler();
        inventoryId = 1;
        periodSelection = b.getString("period");

        parts = periodSelection.split(" ");
        min = Long.parseLong(parts[0]);
        time = min * 60 * 1000;
        killMe = false;
        handler.postDelayed(check, time);
    }

}


private final Runnable check = new Runnable() { 

    @Override
    public void run() {
        // TODO Auto-generated method stub
        if(killMe)
            return;
        Start();
        handler.postDelayed(check, time);
    }
};

@Override
public void onDestroy(){
    Stop();
    super.onDestroy();

}

public void Start(){
    //do smtg
}

public void Stop(){
    handler.removeCallbacksAndMessages(check);
    killMe = true;
    helper.close();
}
}


我搜索了这个问题,并使用AlarmManager启动了AlarmManager服务

Calendar cal = Calendar.getInstance();

Intent intent = new Intent(mContext, RootAccessService.class);
PendingIntent pintent = PendingIntent.getService(mContext, 0, intent, 0);

AlarmManager alarm = (AlarmManager)mContext.getSystemService(Context.ALARM_SERVICE);
alarm.setRepeating(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), Integer.parseInt(parts[0])*60*1000, pintent);
Calendar cal = Calendar.getInstance();

Intent intent = new Intent(mContext, RootAccessService.class);
PendingIntent pintent = PendingIntent.getService(mContext, 0, intent, 0);

AlarmManager alarm = (AlarmManager)mContext.getSystemService(Context.ALARM_SERVICE);
alarm.setRepeating(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), Integer.parseInt(parts[0])*60*1000, pintent);