-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathservicecode.txt
More file actions
55 lines (42 loc) · 1.71 KB
/
servicecode.txt
File metadata and controls
55 lines (42 loc) · 1.71 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*
private Looper mServiceLooper;
private ServiceHandler mServiceHandler;
NotificationListener notificationListener = new NotificationListener();
// Handler that receives messages from the thread
private final class ServiceHandler extends Handler {
public ServiceHandler(Looper looper) {
super(looper);
}
}
@Override
public void onCreate() {
Context context = getApplicationContext();
// Start up the thread running the service. Note that we create a
// separate thread because the service normally runs in the process's
// main thread, which we don't want to block. We also make it
// background priority so CPU-intensive work will not disrupt our UI.
Log.i("main", "main-onCreate");
HandlerThread thread = new HandlerThread("ServiceStartArgument", Process.THREAD_PRIORITY_BACKGROUND);
thread.start();
// Get the HandlerThread's Looper and use it for our Handler
mServiceLooper = thread.getLooper();
mServiceHandler = new ServiceHandler(mServiceLooper);
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
Log.i("main","main-onStart");
Toast.makeText(getApplicationContext(), "service starting", LENGTH_SHORT).show();
return START_STICKY;
}
@Override
public IBinder onBind(Intent intent) {
// We don't provide binding, so return null
return null;
}
@Override
public void onDestroy() {
Toast.makeText(getApplicationContext(), "service done", LENGTH_SHORT).show();
Log.i("main","main-Destroy");
}
}
class NotificationListener extends NotificationListenerService { */