External Link Config
This class gives the possibility to configure and customise the extract of link information (metadata) using any third library.
The following example gives an idea how to use and customise the extract link :
class CustomBaseLinkProvider implements ILinkProvider {
private ILinkRequester mLinkRequester;
CustomBaseLinkProvider(ILinkRequester linkRequester)
{
mLinkRequester = linkRequester;
}
public void getWebsiteMetadata(Context context, String link, IMetadataCallback callback)
{
// execute an HTTP request using link parameter and provide a feedback using the
// callback parameter
if (mLinkRequester != null) {
mLinkRequester.doRequest(context, link, new ILinkRequester.Callback() {
public void onResponse(JSONObject jsonObject) {
if (callback != null) {
LinkModel linkModel = //create a LinkModel based on jsonObject;
callback.onSuccess(linkModel);
}
}
public void onNetworkError() {
if (callback != null) {
callback.onFailed();
}
}
public void onError() {
if (callback != null) {
callback.onFailed();
}
}
});
}
}
}
ExternalLinkConfig externalLinkConfig =
new ExternalLinkConfig
.Builder()
.provider(new CustomBaseLinkProvider(new DefaultLinkRequester()))
.build();
SDKEnvironment.initExternalLinkConfig(externalLinkConfig);
Content copied to clipboard
Instead of using the DefaultLinkRequester, you can customize it by implementing the com.streamwide.smartms.lib.template.link.ILinkRequester as below :
class CustomLinkRequester implements ILinkRequester {
public void doRequest(Context context, String url, Callback callback) {
}
}
Content copied to clipboard