SHARE
TWEET

ServiceHelper

MaryOrange Nov 22nd, 2012 20 Never
  1. package com.example.persons.service;
  2.  
  3. import android.content.Context;
  4. import android.content.Intent;
  5. import android.os.ResultReceiver;
  6.  
  7. public class PersonServiceHelper {
  8.  
  9.         private static PersonServiceHelper _instance = null;
  10.  
  11.         private PersonServiceHelper () {
  12.         }
  13.  
  14.         private synchronized static void createInstance () {
  15.                 if ( _instance == null )
  16.                         _instance = new PersonServiceHelper ();
  17.         }
  18.  
  19.         public static PersonServiceHelper getInstance () {
  20.                 if ( _instance == null )
  21.                         createInstance ();
  22.                 return _instance;
  23.         }
  24.  
  25.         public void getPersons ( Context context, ResultReceiver receiver ) {
  26.                 final Intent intent = new Intent ( Intent.ACTION_SYNC, null, context, PersonService.class );
  27.                 intent.putExtra ( PersonService.EXTRA_STATUS, receiver );
  28.                 intent.putExtra ( PersonService.EXTRA_REST_OPERATION, PersonService.GENERAL_REST_OPERATION );
  29.                 context.startService ( intent );
  30.         }
  31. }
RAW Paste Data
Top