Skip to content

Backend Connectivity

Initialize Connection Parameters Instance and Save its Reference for Global Access

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
String applicationVersion="1.0",
    baseUrl="https://mobileservices-youraccount.hana.ondemand.com",//CPms URL
    appId="your_application_id",                                   //CPms AppId
    deviceId="12345";

SettingsParameters settingsParameters =
    new SettingsParameters(baseUrl, appId, deviceId, applicationVersion);
CpmsParameters.init(settingsParameters);

// Get saved reference to configure AppHeadersInterceptor to send client registration headers
AppHeadersInterceptor appHeadersInterceptor = 
    new AppHeadersInterceptor(CpmsParameters.getSettingsParameters());

Initialize OkHttpClient Instance and Save its Reference for Global Access

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
AppHeadersInterceptor appHeadersInterceptor = 
    new AppHeadersInterceptor(CpmsParameters.getSettingsParameters());
ClientProvider.set( new OkHttpClient.Builder()
    .addInterceptor(appHeadersInterceptor)
    .addInterceptor(new CsrfTokenInterceptor(
        CpmsParameters.getSettingsParameters().getBackendUrl()))
    .authenticator(new BasicAuthDialogAuthenticator())
    .cookieJar(new WebkitCookieJar())
    .build());

// Get saved OkHttpClient reference
OkHttpClient okHttpClient = ClientProvider.get();