File tree Expand file tree Collapse file tree 1 file changed +76
-0
lines changed Expand file tree Collapse file tree 1 file changed +76
-0
lines changed Original file line number Diff line number Diff line change
1
+
2
+
3
+ /**
4
+ * Created by hussienalrubaye on 10/1/16.
5
+ */
6
+
7
+ public class LocationService extends Service
8
+ {
9
+
10
+ @ Override
11
+ public void onCreate ()
12
+ {
13
+ super .onCreate ();
14
+
15
+ }
16
+
17
+ @ Override
18
+ public int onStartCommand (Intent intent , int flags , int startId )
19
+ {
20
+
21
+
22
+ return START_NOT_STICKY ;
23
+ }
24
+
25
+ @ Override
26
+ public IBinder onBind (Intent intent )
27
+ {
28
+ return null ;
29
+ }
30
+
31
+
32
+
33
+
34
+
35
+
36
+ @ Override
37
+ public void onDestroy () {
38
+ // handler.removeCallbacks(sendUpdatesToUI);
39
+ super .onDestroy ();
40
+ // Log.v("STOP_SERVICE", "DONE");
41
+
42
+ }
43
+
44
+
45
+
46
+
47
+
48
+
49
+ }
50
+
51
+ //Start service
52
+
53
+ Intent callReceiverIntent = new Intent ("com.domain.name.servicename" );
54
+ callReceiverIntent .putExtras (new Intent (context .getApplicationContext (), LocationService .class ));
55
+ context . startService (callReceiverIntent );
56
+
57
+ //
58
+ //Stop service
59
+
60
+ Intent callReceiverIntent = new Intent ("com.domain.name.servicename" );
61
+ callReceiverIntent .putExtras (new Intent (context .getApplicationContext (), LocationService .class ));
62
+ context . stopService (callReceiverIntent );
63
+
64
+ //Config service Mainfest.xml
65
+ /*
66
+
67
+ <service android:name=".LocationService" >
68
+ <intent-filter>
69
+ <action android:name="com.domain.name.servicename" />
70
+ </intent-filter>
71
+ </service>
72
+
73
+ */
74
+
75
+
76
+
You can’t perform that action at this time.
0 commit comments