0

I created a simple html page that when you open it, it will automatically open your default mail application and fill in the To:, Subject: and clear the body of any default data. This works fine on my desktop and my android phone, but I notice that on the phone it wants to default to the HTML Viewer application which does not fire the jquery in the file. Then I notice it will not ask to use either chrome or the default browser. I put firefox on my phone and it allowed me to set that as my default browser. My question is can I put something in my code that will either allow me to choose a default browser (chrome or FF) or force a browser to be the default browser? I read up a little on Android's API Intent filters but I am not sure if this is the right path and if I can actually accomplish this in my simple html page.

<!DOCTYPE HTML>
<HTML>
<HEAD>
    <TITLE>EMAIL: Test</TITLE>
    <META http-equiv="X-UA-Compatible" content="IE=edge">
    <META http-equiv='cache-control' content='no-cache'>
    <META http-equiv='expires' content='0'>
    <META http-equiv='pragma' content='no-cache'>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>

</HEAD>
<BODY>
</BODY>
<script type="text/javascript">

    $(document).ready(function(){
        document.location.href="mailto:test123@gmail.com?subject=Download&body=%20";
    }); // document.ready

</script>
</HTML>
bane3977
  • 75
  • 5

1 Answers1

-1

You can let user choose it via Intent as so:

Intent email = new Intent(Intent.ACTION_SEND);
email.setType("message/rfc822");
email.putExtra(Intent.EXTRA_EMAIL,new String[]{ "recipient@example.com" });
email.putExtra(Intent.EXTRA_SUBJECT,"INSERT SUBJECT HERE");
email.putExtra(Intent.EXTRA_TEXT,"INSERT BODY HERE");
try{
    Intent.createChooser( email, null );
}catch(ActivityNotFoundException e){
    // WHATEVER
}  

Letting the default app handle the email:

Intent intent = new Intent(Intent.ACTION_VIEW);
Uri data = Uri.parse("mailto:?subject=" + subject + "&body=" + body);
intent.setData(data);
startActivity(intent);  

Explanation can be found here: https://stackoverflow.com/a/3312562/1894684

Community
  • 1
  • 1
An SO User
  • 24,612
  • 35
  • 133
  • 221
  • Where does this code reside? Is all of this in my shortcut in the jquery? And is there a script I need to refer to? – bane3977 Dec 06 '14 at 17:22
  • Depends on how you are sending the email – An SO User Dec 06 '14 at 17:26
  • I want to use my html page since i use it as a shortcut on my android device. – bane3977 Dec 06 '14 at 20:27
  • oh :/ well then I don't know. I cant actually wrap my head around what you are trying to do – An SO User Dec 07 '14 at 03:24
  • 1
    Can i use jquery to call these intents? I am not creating an app for the android. Its a basic html page that i created on my pc that i put on my phone as a shortcut. The problem is the device uses html viewer as the default program. I want it to either default automatically to chrome or allow the user to choose the default. But i want the shortcut to hold this intent code. – bane3977 Dec 07 '14 at 12:55
  • I have no idea about `jQuery`. I use `Java` :) – An SO User Dec 07 '14 at 13:30