progressBar = (ProgressBar) findViewById(R.id.progressBar);
// setWebViewClient makes this WebView the default handler for URLs inside the app, so that links are not kicked out to other apps.
- // Save the URL to urlTextBox before loading mainWebView.
+ // Save the URL to formattedUrlString and update urlTextBox before loading mainWebView.
mainWebView.setWebViewClient(new WebViewClient() {
public boolean shouldOverrideUrlLoading(WebView view, String url) {
- urlTextBox.setText(url);
+ formattedUrlString=url;
+ urlTextBox.setText(formattedUrlString);
mainWebView.loadUrl(url);
return true;
}
final Intent intent = getIntent();
if (intent.getData() != null) {
- // Get the intent data.
+ // Get the intent data and convert it to a string.
final Uri intentUriData = intent.getData();
-
- // Try to parse the intent data and store it in urlData.
- URL urlData = null;
- try {
- urlData = new URL(intentUriData.getScheme(), intentUriData.getHost(), intentUriData.getPath());
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- Webview.formattedUrlString = urlData.toString();
+ Webview.formattedUrlString = intentUriData.toString();
}
// If formattedUrlString is null assign the homepage to it.