{"id":478,"date":"2018-05-29T10:36:39","date_gmt":"2018-05-29T09:36:39","guid":{"rendered":"https:\/\/jonika.nu\/JonasBlogg\/?p=478"},"modified":"2018-05-29T10:36:39","modified_gmt":"2018-05-29T09:36:39","slug":"launch-boxer-mail-client-from-android-app","status":"publish","type":"post","link":"https:\/\/jonika.nu\/JonasBlogg\/archives\/478","title":{"rendered":"Launch Boxer mail client from Android App"},"content":{"rendered":"<p>I spent a good few hours trying to launch Boxer e-mail client from an app i&#8217;m currently working on. I thought it would be piece of cake when i read throught their documentation, and sure, it was easy on iOS using the url scheme awemailclient:\/\/<\/p>\n<p>The documentation did not mention the Android version of Boxer don&#8217;t support this. It took me a few hours to realize url scheme was a dead end when it comes to Android, and another bunch of hours to find out how to do it.<\/p>\n<p>The solution, as always, is quite simple and also make sence. You pretty much do a regular intent of type message\/rfc822. What you need to add to that is code to show only Boxer, not all apps on the phone that can handle e-mails. And that is done with one line of code.<\/p>\n<p>This example is in C# using Xamarin, but i&#8217;m sure it&#8217;s easy to translate to Java if needed:<\/p>\n<pre class=\"lang:c# decode:true \">\/\/Create your intent\r\nvar intent = new Intent(Intent.ActionSend);\r\n\/\/This is what makes boxer the only option!\r\nintent.SetPackage(\"com.boxer.email\");\r\n\/\/Set the type\r\nintent.SetType(\"message\/rfc822\");\r\n\/\/Put in recipient, subject and body\r\nintent.PutExtra(Intent.ExtraEmail, new string[] { \"recipient@contoso.com\" });\r\nintent.PutExtra(Intent.ExtraSubject, \"Hello World\");\r\nintent.PutExtra(Intent.ExtraText, \"This is a message!\"));\r\nAndroid.App.Application.Context.StartActivity(intent);<\/pre>\n<p>&nbsp;<\/p>\n<a href=\"https:\/\/twitter.com\/jonlin76\" class=\"twitter-follow-button\" data-show-count=\"false\" data-size=\"small\">Follow jonlin76<\/a>\n<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=\/^http:\/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+':\/\/platform.twitter.com\/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');<\/script>","protected":false},"excerpt":{"rendered":"<p>I spent a good few hours trying to launch Boxer e-mail client from an app i&#8217;m currently working on. I thought it would be piece of cake when i read throught their documentation, and sure, it was easy on iOS using the url scheme awemailclient:\/\/ The documentation did not mention the Android version of Boxer &hellip; <a href=\"https:\/\/jonika.nu\/JonasBlogg\/archives\/478\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Launch Boxer mail client from Android App<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[59],"tags":[128,125,99,126,127],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/jonika.nu\/JonasBlogg\/wp-json\/wp\/v2\/posts\/478"}],"collection":[{"href":"https:\/\/jonika.nu\/JonasBlogg\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jonika.nu\/JonasBlogg\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jonika.nu\/JonasBlogg\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/jonika.nu\/JonasBlogg\/wp-json\/wp\/v2\/comments?post=478"}],"version-history":[{"count":1,"href":"https:\/\/jonika.nu\/JonasBlogg\/wp-json\/wp\/v2\/posts\/478\/revisions"}],"predecessor-version":[{"id":479,"href":"https:\/\/jonika.nu\/JonasBlogg\/wp-json\/wp\/v2\/posts\/478\/revisions\/479"}],"wp:attachment":[{"href":"https:\/\/jonika.nu\/JonasBlogg\/wp-json\/wp\/v2\/media?parent=478"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jonika.nu\/JonasBlogg\/wp-json\/wp\/v2\/categories?post=478"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jonika.nu\/JonasBlogg\/wp-json\/wp\/v2\/tags?post=478"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}