-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMyService.java
More file actions
58 lines (45 loc) · 1.35 KB
/
Copy pathMyService.java
File metadata and controls
58 lines (45 loc) · 1.35 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
56
57
58
package com.example.root.project;
import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.util.Log;
public class MyService extends Service {
public MyService() {
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
Log.v("Test","in onstart method");
Runnable r = new Runnable() {
@Override
public void run() {
Log.v("Test","in run method");
for(int i = 0; i<5 ;i++){
int Final = 1000;
while (Final>100){
synchronized (this){
Final=Final/10;
Log.v("Test"," In loop.....");
try {
wait(5000);
}catch(Exception e) {
}
}
}
}
}
};
Log.v("Test","Creating a thread....");
Thread thread= new Thread(r);
thread.start();
return Service.START_STICKY;
}
@Override
public IBinder onBind(Intent intent) {
// TODO: Return the communication channel to the service.
return null;
}
@Override
public void onDestroy() {
super.onDestroy();
}
}