{
serviceURL:"https://hcpms-p1743065160trial.hanatrial.ondemand.com",
appID:"com.sap.stepbystep",
connectionID:"com.sap.edm.sampleservice.v2"
}
private final String connectionID = "com.sap.edm.sampleservice.v2";
private String connectionID;
private void getConfiguration() {
ConfigurationLoaderCallback myConfigCallback = new ConfigurationLoaderCallback() {
public void onCompletion(ProviderIdentifier providerId, boolean success) {
Log.d(myTag, "Provider loaded successfully. " + providerId);
try {
JSONObject config = DefaultPersistenceMethod.getPersistedConfiguration(getApplicationContext());
serviceURL = config.getString("serviceURL");
appID = config.getString("appID");
connectionID = config.getString("connectionID");
Log.d(myTag, "Config data is: " + config.toString());
onRegister(null);
} catch (ConfigurationPersistenceException e) {
e.printStackTrace();
} catch (JSONException e) {
e.printStackTrace();
}
}
public void onError(ConfigurationLoader configurationLoader,
ProviderIdentifier providerId,
UserInputs requestedInput,
ConfigurationProviderError error) {
Log.d(myTag, "Provider failed to load. " + error);
}
public void onInputRequired(ConfigurationLoader configurationLoader, UserInputs requestedInput) {
Log.d(myTag, "Provider requires input. " + requestedInput);
}
};
final ConfigurationLoader myLoader = new ConfigurationLoader(getApplicationContext(), myConfigCallback);
myLoader.loadConfiguration();
}
{
"serviceURL":"https://hcpms-p1743065160trial.hanatrial.ondemand.com",
"appID":"com.sap.stepbystep",
"connectionID":"com.sap.edm.sampleservice.v2"
}
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="16dp"
android:paddingRight="16dp">
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<AutoCompleteTextView
android:id="@+id/input"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/browser_actions_bg_grey"
android:imeOptions="actionDone"
android:inputType="text" />
</com.google.android.material.textfield.TextInputLayout;
</FrameLayout>
private ConfigurationLoader discoveryServiceConfigurationLoader;
private void getConfigurationFromDiscoveryService() {
ConfigurationLoaderCallback myConfigCallback = new ConfigurationLoaderCallback() {
public void onCompletion(ProviderIdentifier providerId, boolean success) {
Log.d(myTag, "Provider loaded successfully. " + providerId);
try {
JSONObject config = DefaultPersistenceMethod.getPersistedConfiguration(getApplicationContext());
serviceURL = config.getString("serviceURL");
appID = config.getString("appID");
connectionID = config.getString("connectionID");
Log.d(myTag, "Config data is: " + config.toString());
onRegister(null);
} catch (ConfigurationPersistenceException e) {
e.printStackTrace();
} catch (JSONException e) {
e.printStackTrace();
}
}
public void onError(ConfigurationLoader configurationLoader,
ProviderIdentifier providerId,
UserInputs requestedInput,
ConfigurationProviderError error) {
Log.d(myTag, "Provider failed to load. " + error);
}
public void onInputRequired(ConfigurationLoader configurationLoader, UserInputs requestedInput) {
JSONObject config = null;
//Don't try to download the configuration data if we already have saved data.
try {
config = DefaultPersistenceMethod.getPersistedConfiguration(getApplicationContext());
} catch (ConfigurationPersistenceException e) {
e.printStackTrace();
}
if (config.length() != 0) {
configurationLoader.processRequestedInputs(requestedInput);
}
else {
Log.d(myTag, "Provider requires input. " + requestedInput);
discoveryServiceConfigurationLoader = configurationLoader;
getEmail();
}
}
};
ConfigurationProvider[] providers = new ConfigurationProvider[] {
//new DiscoveryServiceConfigurationProvider(getApplicationContext()) //explicitly using string below to show the value
new DiscoveryServiceConfigurationProvider("com.sap.stepbystep:1.0")
};
final ConfigurationLoader myLoader = new ConfigurationLoader(getApplicationContext(), myConfigCallback, providers);
myLoader.loadConfiguration();
}
//https://stackoverflow.com/questions/10903754/input-text-dialog-android
private void getEmail() { //This dialog could also be provided by the Fiori Onboariding Library
AlertDialog.Builder builder = new AlertDialog.Builder(this, android.R.style.Theme_DeviceDefault_Dialog_NoActionBar_MinWidth);
builder.setMessage("Enter your email address to download the configuration for your app.");
builder.setTitle("Enter email");
//Set up the input
View viewInflated = LayoutInflater.from(this).inflate(R.layout.email_edit_text_layout, (ViewGroup)findViewById(android.R.id.content), false);
final EditText input = (EditText) viewInflated.findViewById(R.id.input);
input.setText("Dan@trial-p1743065160trial.sapmobileplace.com"); //TODO, hardcoded to make it easier to test
builder.setView(viewInflated);
// Set up the buttons
builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
String email4DiscoveryService = input.getText().toString();
Log.d(myTag, "Email is: " + input.getText().toString());
UserInputs inputs = new UserInputs();
ProviderInputs discoveryInputs = new ProviderInputs();
discoveryInputs.addInput(DiscoveryServiceConfigurationProvider.EMAIL_ADDRESS, email4DiscoveryService);
inputs.addProvider(ProviderIdentifier.DISCOVERY_SERVICE_CONFIGURATION_PROVIDER, discoveryInputs);
discoveryServiceConfigurationLoader.processRequestedInputs(inputs);
}
});
builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
});
builder.show();
}
implementation 'com.google.android.material:material:1.0.0'
https://discovery.sapmobilesecure.com/config-api.svc/ApplicationConfigurations/getApplicationConfiguration(AppConfigID='com.sap.stepbystep:1.0',EmailAddress='Dan@trial-p1743065160trial.sapmobileplace.com')
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
36 | |
25 | |
17 | |
13 | |
8 | |
7 | |
7 | |
6 | |
6 | |
6 |