*/\r
package com.owncloud.android.syncadapter;\r
\r
+import com.owncloud.android.utils.Log_OC;\r
+\r
import android.app.Service;\r
import android.content.Intent;\r
import android.os.IBinder;\r
public static final String ACCOUNT_NAME = "ACCOUNT_NAME";\r
public static final String SYNC_RESULT = "SYNC_RESULT";\r
\r
+ // Storage for an instance of the sync adapter\r
+ private static FileSyncAdapter sSyncAdapter = null;\r
+ // Object to use as a thread-safe lock\r
+ private static final Object sSyncAdapterLock = new Object();\r
+ \r
public static String getSyncMessage(){\r
return FileSyncService.class.getName().toString() + SYNC_MESSAGE;\r
}\r
*/\r
@Override\r
public void onCreate() {\r
+ synchronized (sSyncAdapterLock) {\r
+ if (sSyncAdapter == null) {\r
+ sSyncAdapter = new FileSyncAdapter(getApplicationContext(), true);\r
+ }\r
+ }\r
}\r
\r
/*\r
*/\r
@Override\r
public IBinder onBind(Intent intent) {\r
- return new FileSyncAdapter(getApplicationContext(), true).getSyncAdapterBinder();\r
+ return sSyncAdapter.getSyncAdapterBinder();\r
}\r
\r
}\r