forked from ybin/android_notes
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClientActivity.java
More file actions
31 lines (28 loc) · 923 Bytes
/
ClientActivity.java
File metadata and controls
31 lines (28 loc) · 923 Bytes
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
/* ClientActivity.java */
public class ClientActivity extends Activity {
public static final String TAG = "ClientActivity";
private IAIDLServerService mService;
private ServiceConnection mConnection = new ServiceConnection() {
@Override
public void onServiceDisconnected(ComponentName name) {
mService = null;
}
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
mService = IAIDLServerService.Stub.asInterface(service);
try {
Log.d(TAG, "book name: " + mService.getBook().getBookName()
+ ", book price: " + mService.getBook().getBookPrice());
} catch (RemoteException e) {
Log.d(TAG, "remote exception occured.");
}
}
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
bindService(new Intent("com.example.aidldemo.action.aidlservice"),
mConnection, BIND_AUTO_CREATE);
finish();
}
}