Back to project page cs50-final-project-android.
The source code is released under:
MIT License
If you think the Android project cs50-final-project-android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package net.cs50.recipes.sync; /*w w w.j a v a 2s .com*/ import android.app.Service; import android.content.Intent; import android.os.IBinder; import android.util.Log; /** * Service to handle sync requests. * * returns a Binder connection the SyncAdapter */ public class SyncService extends Service { private static final String TAG = "SyncService"; private static final Object sSyncAdapterLock = new Object(); private static SyncAdapter sSyncAdapter = null; /** * create static instance of sync adapter */ @Override public void onCreate() { super.onCreate(); Log.i(TAG, "Service created"); synchronized (sSyncAdapterLock) { if (sSyncAdapter == null) { sSyncAdapter = new SyncAdapter(getApplicationContext(), true); } } } @Override public void onDestroy() { super.onDestroy(); Log.i(TAG, "Service destroyed"); } // Return a Binder handle which allows for us to send new sync requests @Override public IBinder onBind(Intent intent) { return sSyncAdapter.getSyncAdapterBinder(); } }