Skip to content

Instantly share code, notes, and snippets.

@checko
Created July 20, 2012 06:35
Show Gist options
  • Save checko/3149069 to your computer and use it in GitHub Desktop.
Save checko/3149069 to your computer and use it in GitHub Desktop.
private String getJsDialogTitle(String url) {
String title = url;
if (URLUtil.isDataUrl(url)) {
// For data: urls, we just display 'JavaScript' similar to Safari.
title = mContext.getString(R.string.js_dialog_title_default);
} else {
try {
URL aUrl = new URL(url);
// For example: "The page at 'http://www.mit.edu' says:"
title = mContext.getString(R.string.js_dialog_title,
aUrl.getProtocol() + "://" + aUrl.getHost());
} catch (MalformedURLException ex) {
// do nothing. just use the url as the title
}
}
return title;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment