Skip to content

Commit 6c838ee

Browse files
author
hussienalrubaye
committed
service
1 parent 1b9368e commit 6c838ee

File tree

1 file changed

+76
-0
lines changed

1 file changed

+76
-0
lines changed

Service.java

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
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+

0 commit comments

Comments
 (0)