开发者

AlarmManager not starting up

开发者 https://www.devze.com 2023-03-20 06:23 出处:网络
Intent myIntent = new Intent(taskiller.this, taskiller.class); pendingIn开发者_如何学JAVAtent = PendingIntent.getService(taskiller.this, 0, myIntent, 0);
    Intent myIntent = new Intent(taskiller.this, taskiller.class);
    pendingIn开发者_如何学JAVAtent = PendingIntent.getService(taskiller.this, 0, myIntent, 0);

    AlarmManager alarmManager = (AlarmManager)getSystemService(ALARM_SERVICE);
    Calendar calendar = Calendar.getInstance();
    calendar.setTimeInMillis(System.currentTimeMillis());
    //Set taskiller at 20secs
    calendar.add(Calendar.SECOND, 20);
    alarmManager.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis() , pendingIntent);
    Log.i("Securitas", "Set alarm to be triggered");

I want my service to restart itself after a certain time interval but it doesnt seem to happen. Can anybody please advice?

0

精彩评论

暂无评论...
验证码 换一张
取 消