X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/d252a09f53999a90036048d4db33c8b4f2f04c4f..c3d88a0594e32043b2599a37789b7ada4a9ac85a:/src/com/owncloud/android/syncadapter/FileSyncService.java diff --git a/src/com/owncloud/android/syncadapter/FileSyncService.java b/src/com/owncloud/android/syncadapter/FileSyncService.java index 3c999753..1e1e11fd 100644 --- a/src/com/owncloud/android/syncadapter/FileSyncService.java +++ b/src/com/owncloud/android/syncadapter/FileSyncService.java @@ -17,6 +17,8 @@ */ package com.owncloud.android.syncadapter; +import com.owncloud.android.utils.Log_OC; + import android.app.Service; import android.content.Intent; import android.os.IBinder; @@ -37,6 +39,11 @@ public class FileSyncService extends Service { public static final String ACCOUNT_NAME = "ACCOUNT_NAME"; public static final String SYNC_RESULT = "SYNC_RESULT"; + // Storage for an instance of the sync adapter + private static FileSyncAdapter sSyncAdapter = null; + // Object to use as a thread-safe lock + private static final Object sSyncAdapterLock = new Object(); + public static String getSyncMessage(){ return FileSyncService.class.getName().toString() + SYNC_MESSAGE; } @@ -45,6 +52,11 @@ public class FileSyncService extends Service { */ @Override public void onCreate() { + synchronized (sSyncAdapterLock) { + if (sSyncAdapter == null) { + sSyncAdapter = new FileSyncAdapter(getApplicationContext(), true); + } + } } /* @@ -52,7 +64,7 @@ public class FileSyncService extends Service { */ @Override public IBinder onBind(Intent intent) { - return new FileSyncAdapter(getApplicationContext(), true).getSyncAdapterBinder(); + return sSyncAdapter.getSyncAdapterBinder(); } }