-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKillService.java
More file actions
29 lines (25 loc) · 955 Bytes
/
KillService.java
File metadata and controls
29 lines (25 loc) · 955 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package com.example.androidtest;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.os.IBinder;
/**
* Created by linyun on 14-5-7.
*/
public class KillService extends Service {
@Override
public IBinder onBind(Intent intent) {
return null;
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
Context context = getApplicationContext();
PendingIntent pendingIntent = PendingIntent.getActivity(
this, 0, new Intent(context, UrlSchemeTestActivity.class), PendingIntent.FLAG_UPDATE_CURRENT);
AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
alarmManager.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + 5000, pendingIntent);
return super.onStartCommand(intent, flags, startId);
}
}