Knowledge Base - How to handle link (url) annotation?

To open a link annotation (url), you need to implement the listener PDFLayoutListener and in the method OnPDFOpenURI, you can either open the system intent or a custom one...

To open using the system intent:

@Override
public void OnPDFOpenURI(String uri) {
try {
Intent intent = new Intent();
intent.setAction("android.intent.action.VIEW");
Uri content_url = Uri.parse(uri);
intent.setData(content_url);
startActivity(intent);
} catch(Exception e){ }
}

To open using a custom intent:

@Override
public void OnPDFOpenURI(String uri) {
try {
Intent intent = new Intent(this, WebViewAct.class);
intent.putExtra(
"URL", uri);
startActivity(intent);
}
catch(Exception e) { }
}

WebViewAct:
public class WebViewAct extends Activity {

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

WebView mWebView = new WebView(this);
mWebView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));

setContentView(mWebView);

mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.loadUrl(getIntent().getStringExtra("URL"));
}
}
Applies To

RadaeePDF SDK for Android

Details

Created : 2017-01-04 13:51:59, Last Modified : 2017-01-04 13:53:41