Skip to content

Commit c20c277

Browse files
author
silicon ruby
committed
refs #1 Service and BroadcastReceiver
function in service
1 parent 07318df commit c20c277

26 files changed

+31
-3
lines changed

Service/bin/Service.apk

252 KB
Binary file not shown.

Service/bin/classes.dex

612 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
5.82 KB
Loading
3.04 KB
Loading
9.14 KB
Loading
17.5 KB
Loading

Service/bin/resources.ap_

40.3 KB
Binary file not shown.

Service/gen/com/example/service/R.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ public static final class drawable {
2424
public static final int ic_launcher=0x7f020000;
2525
}
2626
public static final class id {
27-
public static final int action_settings=0x7f080003;
27+
public static final int action_settings=0x7f080004;
28+
public static final int add=0x7f080003;
2829
public static final int bind=0x7f080000;
2930
public static final int getStatus=0x7f080002;
3031
public static final int unbind=0x7f080001;
@@ -37,6 +38,7 @@ public static final class menu {
3738
}
3839
public static final class string {
3940
public static final int action_settings=0x7f050001;
41+
public static final int add=0x7f050006;
4042
public static final int app_name=0x7f050000;
4143
public static final int bind=0x7f050003;
4244
public static final int getServiceStatus=0x7f050005;

Service/res/layout/main.xml

+8-1
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,19 @@
2020
android:layout_height="wrap_content"
2121
android:layout_below="@id/bind"
2222
android:text="@string/unbind" />
23-
23+
2424
<Button
2525
android:id="@+id/getStatus"
2626
android:layout_width="match_parent"
2727
android:layout_height="wrap_content"
2828
android:layout_below="@id/unbind"
2929
android:text="@string/getServiceStatus" />
3030

31+
<Button
32+
android:id="@+id/add"
33+
android:layout_width="match_parent"
34+
android:layout_height="wrap_content"
35+
android:layout_below="@id/getStatus"
36+
android:text="@string/add" />
37+
3138
</RelativeLayout>

Service/res/values/strings.xml

+1
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@
77
<string name="bind">Bind Service</string>
88
<string name="unbind">Unbind Service</string>
99
<string name="getServiceStatus">Get Service Status</string>
10+
<string name="add">Add 100</string>
1011

1112
</resources>

Service/src/com/example/service/BindService.java

+8
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ public class MyBinder extends Binder {
1616
public int getCount() {
1717
return count;
1818
}
19+
20+
public void doInBackground() {
21+
doInBackgroundInService();
22+
}
1923
}
2024

2125
@Override
@@ -51,4 +55,8 @@ public void onDestroy() {
5155
this.quit = true;
5256
}
5357

58+
private void doInBackgroundInService() {
59+
this.count += 100;
60+
}
61+
5462
}

Service/src/com/example/service/BindServiceTest.java

+11-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
public class BindServiceTest extends Activity {
1717

18-
private Button bind, unbind, getServiceStatus;
18+
private Button bind, unbind, getServiceStatus, add;
1919
private BindService.MyBinder binder;
2020

2121
private ServiceConnection conn = new ServiceConnection() {
@@ -39,6 +39,7 @@ protected void onCreate(Bundle savedInstanceState) {
3939
bind = (Button) findViewById(R.id.bind);
4040
unbind = (Button) findViewById(R.id.unbind);
4141
getServiceStatus = (Button) findViewById(R.id.getStatus);
42+
add = (Button) findViewById(R.id.add);
4243

4344
final Intent intent = new Intent();
4445
intent.setAction("com.example.service.BindService");
@@ -68,6 +69,15 @@ public void onClick(View v) {
6869
Toast.LENGTH_SHORT).show();
6970
}
7071
});
72+
73+
add.setOnClickListener(new OnClickListener() {
74+
75+
@Override
76+
public void onClick(View v) {
77+
binder.doInBackground();
78+
}
79+
});
80+
7181
}
7282

7383
@Override

0 commit comments

Comments
 (0)