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);
SettingsProvider.set(settingsParameters);

// Configure AppHeadersInterceptor to send client registration headers with the saved SettingsParameters reference
AppHeadersInterceptor appHeadersInterceptor =
    new AppHeadersInterceptor();

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();
ClientProvider.set( new OkHttpClient.Builder()
    .addInterceptor(appHeadersInterceptor)
    .addInterceptor(new CsrfTokenInterceptor(
        SettingsProvider.get().getBackendUrl()))
    .authenticator(new BasicAuthDialogAuthenticator())
    .cookieJar(new WebkitCookieJar())
    .build());

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