I've got this working as it should using the following code. All http urls open as they should within the webview, "tel:" link opens as it should in dialler, and "mailto:" link opens as it should in email client.
But my problem is how do I change the subject of the "mailto:" link to something different instead of its pre-defined subject. I'm guessing there should be 2 seperate intents, 1 for "tel:" link & 1 for "mailto:" link. I simply don't know how to put the code into the shouldOverrideUrlLoading method below. Or maybe I'm using the wrong method for what I require.
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if( url.startsWith("http:") || url.startsWith("https:") ) {
return false;
}
// Otherwise allow the OS to handle it
Intent intent = new Intent(Intent.ACTION_VIEW,
Uri.parse(url));
startActivity(intent);
return true;
}
I managed to get my own subject "mailto:" working with Intent, but without the "tel:" link included in code. So how can I do both plus use my own subject in "mailto:" link?
Any ideas or suggestions will be much appreciated!
When you detect mailto: try appending "?subject=custom" to it. Something like this I guess:
This is my solution & it works for me. I hope it helps anyone else with the same issue I had.
Complete
MainActivity
for all mailto link recipient.