Return to key-value service Key Value service
1: package com.voipplus.mmsclient.serviceLocalStorage;
2:
3: import android.content.ComponentName;
4: import android.content.Context;
5: import android.content. ;
6: import android.content.ServiceConnection;
7: import android.os.IBinder;
8: import android.util.Log;
9:
10: public class KeyValueServiceStarter {
11: private static final String TAG = "KeyValueServiceStarter";
12: private KeyValueService keyValueService;
13: private boolean isBound = false;
14: private Context context;
15: private KeyValueServiceConnectionListener listener;
16:
17: public interface KeyValueServiceConnectionListener {
18: void onKeyValueServiceConnected(KeyValueService service);
19: }
20:
21: public KeyValueServiceStarter(Context context, KeyValueServiceConnectionListener listener) {
22: this.context = context;
23: this.listener = listener;
24: }
25:
26: private ServiceConnection connection = new ServiceConnection() {
27: @Override
28: public void onServiceConnected(ComponentName className, IBinder service) {
29: KeyValueService.LocalBinder binder = (KeyValueService.LocalBinder) service;
30: keyValueService = binder.getService();
31: isBound = true;
32: Log.d(TAG, "KeyValueService connected");
33: if (listener != null) {
34: listener.onKeyValueServiceConnected(keyValueService);
35: }
36: }
37:
38: @Override
39: public void onServiceDisconnected(ComponentName arg0) {
40: isBound = false;
41: Log.d(TAG, "KeyValueService disconnected");
42: }
43: };
44:
45: public void bind() {
46: intent = new (context, KeyValueService.class);
47: context.bindService(intent, connection, Context.BIND_AUTO_CREATE);
48: }
49:
50: public void unbind() {
51: if (isBound) {
52: context.unbindService(connection);
53: isBound = false;
54: }
55: }
56:
57: public void startAndBindService() {
58: intent = new (context, KeyValueService.class);
59: context.startService(intent);
60: context.bindService(intent, connection, Context.BIND_AUTO_CREATE);
61: }
62: }
63:
Return to key-value service
AndroidMosaic context:
- 2025 year: Resolve class conflicts #AndroidMosaic
- 2025 year: Application level parameters in configuration #AndroidMosaic
- 2025 year: Create test with junit and pass or dismiss test before application launch #AndroidMosaic
- 2025 year: Ask special permission and listen answer #AndroidMosaic
- 2025 year: Service lifecycle #AndroidMosaic
- 2025 year: AtomicInteger and accept service callback in UI thread, stop progressBar that was run in UiThread #AndroidMosaic
- 2025 year: Generate random data and pass it to RecyclerView with Adapter #AndroidMosaic
- 2025 year: Pass data to new form with Intent and getParcelableExtra #AndroidMosaic
- 2025 year: Access to Contact list #AndroidMosaic
- 2025 year: Using Query and Cursor to read data sequence and fill DataAdapter for RecyclerView #AndroidMosaic
- 2025 year: Custom TabSwithcer #AndroidMosaic
- 2025 year: Custom Dropdownlist with default value based on Spinner #AndroidMosaic
- 2025 year: Create MMS service and route MMS to Emulator #AndroidMosaic
- 2025 year: Vector drawable - fastest way to create icons #AndroidMosaic
- 2025 year: Technique to create Button with own rectangle shape #AndroidMosaic
- 2025 year: Simple HTTP service #AndroidMosaic
- 2025 year: Simple key-value service with Local Storage #AndroidMosaic
- 2025 year: Cryptographic local storage key-value service #AndroidMosaic
- 2025 year: WebRTC service #AndroidMosaic
- 2025 year: SIP service #AndroidMosaic
- 2025 year: Global objects with references to all application services #AndroidMosaic
Comments (
)

Link to this page:
http://www.vb-net.com/AndroidMosaic/KeyValueServiceStarter.htm
|