(FRONT) FRONT (2025)

Return to main page CryptoStorageServiceStarter

   1:  package com.voipplus.mmsclient.serviceLocalStorage;
   2:  
   3:  import android.content.ComponentName;
   4:  import android.content.Context;
   5:  import android.content.Intent;
   6:  import android.content.ServiceConnection;
   7:  import android.os.IBinder;
   8:  import android.util.Log;
   9:  
  10:  public class CryptoStorageServiceStarter {
  11:      private static final String TAG = "CryptoStorageServiceStarter";
  12:      private CryptoStorageService cryptoStorageService;
  13:      private boolean isBound = false;
  14:      private Context context;
  15:      private ServiceConnectionCallback listener;
  16:  
  17:      public interface ServiceConnectionCallback {
  18:          void onCryptoStorageServiceConnected(CryptoStorageService service);
  19:      }
  20:  
  21:      public CryptoStorageServiceStarter(Context context, ServiceConnectionCallback 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:              CryptoStorageService.LocalBinder binder = (CryptoStorageService.LocalBinder) service;
  30:              cryptoStorageService = binder.getService();
  31:              isBound = true;
  32:              Log.d(TAG, "CryptoStorageService connected");
  33:              if (listener != null) {
  34:                  listener.onCryptoStorageServiceConnected(cryptoStorageService);
  35:              }}
  36:  
  37:          @Override
  38:          public void onServiceDisconnected(ComponentName arg0) {
  39:              isBound = false;
  40:              Log.d(TAG, "CryptoStorageService disconnected");
  41:          }
  42:      };
  43:  
  44:      public void bind() {
  45:          Intent intent = new Intent(context, CryptoStorageService.class);
  46:          context.bindService(intent, connection, Context.BIND_AUTO_CREATE);
  47:      }
  48:  
  49:      public void unbind() {
  50:          if (isBound) {
  51:              context.unbindService(connection);
  52:              isBound = false;
  53:          }
  54:      }
  55:      public void startAndBindService() {
  56:          Intent intent = new Intent(context, CryptoStorageService.class);
  57:          context.startService(intent);
  58:          context.bindService(intent, connection, Context.BIND_AUTO_CREATE);
  59:      }
  60:  }
  61:  

Return to main page




AndroidMosaic context:



Comments ( )
<00>  <01>  <02>  <03>  <04>  <05>  <06>  <07>  <08>  <09>  <10>  <11>  <12>  <13>  <14>  <15>  <16>  <17>  <18>  <19>  <20>  <21>  <22>  <23>  <24>  <25
Link to this page: http://www.vb-net.com/AndroidMosaic/CryptoStorageServiceStarter.htm
<TAGS>  <ARTICLES>  <FRONT>  <CORE>  <MVC>  <ASP>  <NET>  <DATA>  <TASK>  <XML>  <KIOSK>  <NOTES>  <SQL>  <LINUX>  <MONO>  <FREEWARE>  <DOCS> <TRAVELS> <FLOWERS> <RESUME> < THANKS ME>