Android

Our API is RESTful and responds in JSON. Gerencianet uses OAuth to provide authorized access to the API. Our NodeJS SDK is already prepared to perform this authentication automatically.

Below, check out the procedures for installing the Gerencianet SDK in Android:


Pre requirements

  • Android 7.0+

Installation via gradle

implementation 'br.com.gerencianet.mobile:gn-api-sdk-android:1.0.0'

Tested with

  • Android 7.0 e 11.0

Basic use

Requires the module and packages:

import br.com.gerencianet.mobile.Gerencianet;

Although web services responses are in json format, the SDK will convert any server response to a Map <String, Object>. The code must be inside a try-catch and exceptions can be handled as follows:

try {
/* code */
} catch(GerencianetException e) {
/* Gerencianet's api errors will come here */
} catch(Exception ex) {
/* Other errors will come here */
}

For homologation environment


Instantiate the module passing its Client_Id, Client_Secret and sandbox being equal to true:

HashMap<String, Object> options = new HashMap<String Object>();
options.put("client_id", "client_id ");
options.put("client_secret", "client_secret");
options.put("sandbox", true);
Gerencianet gn = new Gerencianet(options);

For production environment


To change the environment to production, just set the third sandbox to false, and its production Client_Id and Client_Secret:

HashMap<String, Object> options = new HashMap<String Object>();
options.put("client_id", "client_id ");
options.put("client_secret", "client_secret");
options.put("sandbox", false);
Gerencianet gn = new Gerencianet(options);

PIX API

To use the PIX API, it is necessary to inform the certificate path inside the assets folder and pass the context's assets as a parameter.

HashMap<String, Object> options = new HashMap<String Object>();
options.put("client_id", "client_id ");
options.put("client_secret", "client_secret");
options.put("pix_cert", "./cert.p12");
options.put("sandbox", false);
Gerencianet gn = new Gerencianet(options, context.getAssets());