Return to SIP service SIP service starter
1: package com.voipplus.mmsclient.Sip;
2:
3: import android.content.*;
4: import android.os.IBinder;
5: import android.util.Log;
6:
7: public class SipServiceStarter {
8: private static final String TAG = "SipServiceStarter";
9: private SipService sipService;
10: private boolean isBound = false;
11: private final Context context;
12: private final SipServiceConnectionListener listener;
13:
14: public interface SipServiceConnectionListener {
15: void onSipServiceConnected(SipService service);
16: }
17:
18: public SipServiceStarter(Context context, SipServiceConnectionListener listener) {
19: this.context = context;
20: this.listener = listener;
21: }
22:
23: private final ServiceConnection connection = new ServiceConnection() {
24: @Override
25: public void onServiceConnected(ComponentName className, IBinder service) {
26: SipService.LocalBinder binder = (SipService.LocalBinder) service;
27: sipService = binder.getService();
28: isBound = true;
29: SipUtils.debugInfo(TAG, "✅ SipService connected.", sipService.getSipState());
30: if (listener != null) listener.onSipServiceConnected(sipService);
31: }
32:
33: @Override
34: public void onServiceDisconnected(ComponentName arg0) {
35: isBound = false;
36: SipUtils.debugInfo(TAG, "❌ SipService disconnected.", null);
37: }
38: };
39:
40: public void startAndBindService() {
41: intent = new (context, SipService.class);
42: context.startService(intent);
43: context.bindService(intent, connection, Context.BIND_AUTO_CREATE);
44: }
45: }
46:
Return to SIP service
AndroidMosaic context:
Comments (
)
)
Link to this page:
http://www.vb-net.com/AndroidMosaic/Index20.htm
|
|