CopyPastor

Detecting plagiarism made easy.

Score: 0.8892143902679285; Reported for: String similarity Open both answers

Possible Plagiarism

Plagiarized on 2020-08-28
by Taha Gorme

Original Post

Original - Posted on 2013-08-01
by onit



            
Present in both answers; Present only in the new answer; Present only in the old answer;

The problem is you need to send an [Intent][1] to the default web browser to open the link. What you are doing is just calling a different method in your Webview to handle the link. Whenever you want another app to handle something you need to use Intents. Try this code instead.
private class CustomWebViewClient extends WebViewClient { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { if(url.contains("yourwebsiteurl.com")) { view.loadUrl(url); } else { Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); startActivity(i); } return true; } }

[1]: http://developer.android.com/reference/android/content/Intent.html


share on whatsapp
Intent whatsappIntent = new Intent(Intent.ACTION_SEND); whatsappIntent.setType("text/plain"); whatsappIntent.setPackage("com.whatsapp"); whatsappIntent.putExtra(Intent.EXTRA_TEXT, "The text you wanted to share"); try { activity.startActivity(whatsappIntent); } catch (android.content.ActivityNotFoundException ex) { Toast.makeText(MainActivity.this, "Whatsapp not installed", Toast.LENGTH_LONG).show(); }
The problem is you need to send an [Intent][1] to the default web browser to open the link. What you are doing is just calling a different method in your Webview to handle the link. Whenever you want another app to handle something you need to use Intents. Try this code instead.
private class CustomWebViewClient extends WebViewClient { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { if(url.contains("message2space.es.vu")) { view.loadUrl(url); } else { Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); startActivity(i); } return true; } }

[1]: http://developer.android.com/reference/android/content/Intent.html

        
Present in both answers; Present only in the new answer; Present only in the old answer;