We can not use the Rainbow SDK without first creating an instance of the Rainbow class. That class is so important that it exists as a singleton:
Rainbow.init(<Context>); Rainbow rainbow = Rainbow.getInstance();
Once we have that instance, we then need to pass the appSecret and a filePath:
We get the <secret> from this site, when we registered the app. The <path> is used to store the connected Cloud Service accounts. It may be null, but in this case your users will have to connect to their accounts every time they start your app.
The last step is to provide the keys for each Cloud Service. These are the clientID, clientSecret and callbacks that you put on a Cloud Service’s site. Each Cloud Service uses a different name for these keys, and thus we created a JSONObject that you can use it as a template. You can remove the Cloud Services that you are not interested in or you can complete only those that you are.
JSONObject services = createServiceKeys(); rainbow.addServiceKeys(services);
Now we are ready to start using the Rainbow SDK. Based on the non-empty values that we had in the JSONObject object in the addServiceKeys() method, the method getServices() will return the Cloud Services that you can use:
HashMap<String, RService>services = rainbow.getServices();
The key of that HashMap is the name of the Cloud Service, and the value is an instance of the RService class. The name for each Cloud Service is the following:
If you use a different name you will get a null object. Once you have the instance of the RService class, you can either list the connected accounts (RServiceItem instance) or you can connect to a new account. From the RServiceItem instance you can get the RManager instance and then perform any of the supported action on that Cloud Service.