accessing the Couchlite Manager shared instance on Android

79 views
Skip to first unread message

Zumo

unread,
Oct 29, 2014, 2:36:02 PM10/29/14
to mobile-c...@googlegroups.com

Hi Everyone,

I am writing an app using the Phonegap Couchlite plugin and I need to access the Manager instance from another in house plugin.
When on IOS I use :
 CBLManager *manager = [CBLManager sharedInstance]; 
And it works OK

On Android I am trying :
 Manager manager = Manager.getSharedInstance(); 

As a result I am getting an Exception :
  • e = {java.lang.UnsupportedOperationException@831704908064}"java.lang.UnsupportedOperationException: getSharedInstance() is not a valid API call on Android. Pure java version coming soon" 

What is the recommended approach in Android to get access to the Couchlite Manager if getSharedInstance is not supported ?

Thanks a lot for your help
Christian

Traun Leyden

unread,
Nov 3, 2014, 3:41:20 PM11/3/14
to mobile-c...@googlegroups.com

See example here:


public class Application extends android.app.Application {
    private Manager manager;
    private static Context mContext;
    
    ...
    
    @Override
    public void onCreate() {
        super.onCreate();
        mContext = getApplicationContext();
        try {
            /*
             * In Java the Manager instance and all the objects descending
             * from it may be used on any thread.
             */
            manager = new Manager(new AndroidContext(mContext), Manager.DEFAULT_OPTIONS);
        } catch (IOException e) {
            Log.e(TAG, "Cannot create Manager instance", e);
            return;
        }
    }
}

--
You received this message because you are subscribed to the Google Groups "Couchbase Mobile" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mobile-couchba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mobile-couchbase/e6a424b4-06ad-40cc-9025-afb1085cf93d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Zumo

unread,
Nov 4, 2014, 3:18:32 AM11/4/14
to mobile-c...@googlegroups.com
Thanks a lot for your post , 

I wanted to avoid having to change the code in the CBL phonegap plugin (the code that creates the Manager) , but seems like I'll have to ..
cheers

Traun Leyden

unread,
Nov 4, 2014, 1:25:27 PM11/4/14
to mobile-c...@googlegroups.com

Zumo

unread,
Nov 5, 2014, 3:48:41 AM11/5/14
to mobile-c...@googlegroups.com
Oh I see
Thanks a lot Traun
Reply all
Reply to author
Forward
0 new messages