public class MainActivity extends Activity {
private WebView webview;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
webview = (WebView) findViewById(R.id.webView1); // Declare webview in .xml file
webview.setWebViewClient(new HelloWebViewClient());
webview.getSettings().setJavaScriptEnabled(true);
webview.loadUrl("http://www.YOURWEBLINK.com/mpages//advertise/");
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if ((keyCode == KeyEvent.KEYCODE_BACK) && webview.canGoBack()) {
webview.goBack();
return true;
}
return super.onKeyDown(keyCode, event);
}
private class HelloWebViewClient extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if(url.startsWith("mailto:")){
MailTo mt = MailTo.parse(url);
Intent intent = new Intent (Intent.ACTION_VIEW , Uri.parse("mailto:" + "contactus@YourDomain.com"));// MAIL SEND TO
intent.putExtra(Intent.EXTRA_SUBJECT, "Subject"); // SUBJECT
intent.putExtra(Intent.EXTRA_TEXT, "Please refer www.macmaker.blogspot.com for more details...Thanks RONAK PANDYA ");// Mail Detail
startActivity(intent);
view.reload();
return true;
}
else{
view.loadUrl(url);
}
return true;
}
};
// mWebView.setWebViewClient(mWebClient); }
}
No comments:
Post a Comment