Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

ServiceHelper

By: MaryOrange on Nov 22nd, 2012  |  syntax: Java  |  size: 0.89 KB  |  views: 20  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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. }