Skip to content

Back End Connectivity

Initialize Connection Parameters Instance and Save Its Reference for Global Access

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

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();

Last update: April 14, 2021