{"id":4596,"date":"2018-06-11T15:38:22","date_gmt":"2018-06-11T10:08:22","guid":{"rendered":"https:\/\/www.innovationm.com\/blog\/?p=4596"},"modified":"2018-06-11T15:38:22","modified_gmt":"2018-06-11T10:08:22","slug":"create-chooser-sending-email-using-intent","status":"publish","type":"post","link":"https:\/\/www.innovationm.com\/blog\/create-chooser-sending-email-using-intent\/","title":{"rendered":"Create Chooser | Sending Email Using Intent"},"content":{"rendered":"<p>&nbsp;<\/p>\n<p>In this blog, we are going to discuss first Intent in short and then create chooser and email sending process using intent.<\/p>\n<h1>Intent<\/h1>\n<p>An intent is an object that provides runtime binding between seprate components (such as two activity etc). It can be used as signal to the android operating system that certain event has occured.<\/p>\n<h1>Intent Object<\/h1>\n<p>An intent object is bundle of information which is used by the components.<\/p>\n<pre class=\"\">Intent intent = new Intent();<\/pre>\n<p>Intent object contains following property-<\/p>\n<h6>1. Action<br \/>\n2. Data<br \/>\n3. Category<br \/>\n4. Extras<\/h6>\n<h1>Intent Type<\/h1>\n<p>Intent are following two types:<\/p>\n<h3>1. Explicit Intent<\/h3>\n<p>Explicit Intent is the intent in which we explicitly define the component name.<\/p>\n<pre class=\"\">Intent explicitIntent = new Intent(this,SecondActivity.class);<\/pre>\n<h3>2. Implicit Intent<\/h3>\n<p>Implicit Intent is the intent in which we defines action which we want to perform instead of defining component name.<\/p>\n<pre class=\"\">Intent implicitIntent = new Intent();\r\nimplicitIntent.setAction(Intent.ACTION_SEND);<\/pre>\n<h2>createChooser()<\/h2>\n<p>If we want to access any Uri like geographical co-ordinate and market store applications then use createChooser(). It returns Intent object. If we did not use create chooser then app will be crash when there is no applications to access the Uri. So whenever we use implicit Intent then we should use create chooser.<\/p>\n<pre class=\"\">Intent intent = new intent(Intent.ACTION_SEND);\r\nIntent chooserIntent = Intent.createChooser(intent,\"Send Email\")\r\nstartActivity(chooserIntent);<\/pre>\n<h1>Sending Email Using Intent<\/h1>\n<p>To send an email from an application you do not have to implement an email client,but you can use default email app provided by android. For this we need to write an activity that launches an email client using implicit intent with right action and data. In the following example we are going\u00a0 to send an email from our app that launch existing email client<\/p>\n<p><b>EXTRA_EMAIL &#8211;\u00a0<\/b>A String[] holding e-mail addresses that should be delivered to.<\/p>\n<p><b>EXTRA_SUBJECT &#8211;\u00a0<\/b>A constant string holding the desired subject line of a message.<\/p>\n<p><b>EXTRA_TEXT &#8211;\u00a0<\/b>A constant Char Sequence that is associated with the Intent, used email body.<\/p>\n<p><b>EXTRA_BCC &#8211;\u00a0<\/b>A String[] holding e-mail addresses that should be blind carbon copied.<\/p>\n<p><b>EXTRA_CC &#8211;\u00a0<\/b>A String[] holding e-mail addresses that should be carbon copied.<\/p>\n<p><b>EXTRA_TITLE &#8211;\u00a0<\/b>A Char Sequence dialog title to provide to the user when used with a ACTION_CHOOSER.<\/p>\n<pre class=\"\">Intent intent = new Intent(Intent.ACTION_SEND);\r\n\/\/To send an email you need to specify\u00a0mailto\u00a0as URI\r\nintent.setData(Uri.parse(\"mailto:\"));\r\nString[] to = {\"kps@gmail.com\",skaa@gmail.com};\r\nintent.putExtra(Intent.EXTRA_EMAIL,to);\r\nintent.putExtra(Intent.EXTRA_SUBJECT,\"Sending Email Using Implicit Intent\");\r\nintent.putExtra(Intent.EXTRA_TEXT,\"Email body message\");\r\n\r\n\/\/this is mime type of email without it no activity can be found to send email.\r\nintent.setType(\"message\/rfc822\");\r\nchooserIntent = Intent.createChooser(intent,\"Send Email\");\r\nstartActivity(chooserIntent);<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; In this blog, we are going to discuss first Intent in short and then create chooser and email sending process using intent. Intent An intent is an object that provides runtime binding between seprate components (such as two activity etc). It can be used as signal to the android operating system that certain event [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":4687,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[71],"tags":[159],"class_list":["post-4596","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-mobile","tag-android"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Create Chooser | Sending Email Using Intent - InnovationM - Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.innovationm.com\/blog\/create-chooser-sending-email-using-intent\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Create Chooser | Sending Email Using Intent - InnovationM - Blog\" \/>\n<meta property=\"og:description\" content=\"&nbsp; In this blog, we are going to discuss first Intent in short and then create chooser and email sending process using intent. Intent An intent is an object that provides runtime binding between seprate components (such as two activity etc). It can be used as signal to the android operating system that certain event [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.innovationm.com\/blog\/create-chooser-sending-email-using-intent\/\" \/>\n<meta property=\"og:site_name\" content=\"InnovationM - Blog\" \/>\n<meta property=\"article:published_time\" content=\"2018-06-11T10:08:22+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.innovationm.com\/blog\/wp-content\/uploads\/2018\/06\/Kripa_image.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1123\" \/>\n\t<meta property=\"og:image:height\" content=\"663\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"InnovationM Admin\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"InnovationM Admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/create-chooser-sending-email-using-intent\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/create-chooser-sending-email-using-intent\\\/\"},\"author\":{\"name\":\"InnovationM Admin\",\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/#\\\/schema\\\/person\\\/a831bf4602d69d1fa452e3de0c8862ed\"},\"headline\":\"Create Chooser | Sending Email Using Intent\",\"datePublished\":\"2018-06-11T10:08:22+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/create-chooser-sending-email-using-intent\\\/\"},\"wordCount\":346,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/create-chooser-sending-email-using-intent\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/wp-content\\\/uploads\\\/2018\\\/06\\\/Kripa_image.png\",\"keywords\":[\"Android\"],\"articleSection\":[\"Mobile\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/create-chooser-sending-email-using-intent\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/create-chooser-sending-email-using-intent\\\/\",\"url\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/create-chooser-sending-email-using-intent\\\/\",\"name\":\"Create Chooser | Sending Email Using Intent - InnovationM - Blog\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/create-chooser-sending-email-using-intent\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/create-chooser-sending-email-using-intent\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/wp-content\\\/uploads\\\/2018\\\/06\\\/Kripa_image.png\",\"datePublished\":\"2018-06-11T10:08:22+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/#\\\/schema\\\/person\\\/a831bf4602d69d1fa452e3de0c8862ed\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/create-chooser-sending-email-using-intent\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/create-chooser-sending-email-using-intent\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/create-chooser-sending-email-using-intent\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/wp-content\\\/uploads\\\/2018\\\/06\\\/Kripa_image.png\",\"contentUrl\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/wp-content\\\/uploads\\\/2018\\\/06\\\/Kripa_image.png\",\"width\":1123,\"height\":663},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/create-chooser-sending-email-using-intent\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Create Chooser | Sending Email Using Intent\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/\",\"name\":\"InnovationM - Blog\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/#\\\/schema\\\/person\\\/a831bf4602d69d1fa452e3de0c8862ed\",\"name\":\"InnovationM Admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/5c99d9eece9dfbc82297cf34ddd58e9fe05bb52fe66c8f6bf6c0a45bfb6d7629?s=96&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/5c99d9eece9dfbc82297cf34ddd58e9fe05bb52fe66c8f6bf6c0a45bfb6d7629?s=96&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/5c99d9eece9dfbc82297cf34ddd58e9fe05bb52fe66c8f6bf6c0a45bfb6d7629?s=96&r=g\",\"caption\":\"InnovationM Admin\"},\"sameAs\":[\"http:\\\/\\\/www.innovationm.com\\\/\"],\"url\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/author\\\/innovationmadmin\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Create Chooser | Sending Email Using Intent - InnovationM - Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.innovationm.com\/blog\/create-chooser-sending-email-using-intent\/","og_locale":"en_US","og_type":"article","og_title":"Create Chooser | Sending Email Using Intent - InnovationM - Blog","og_description":"&nbsp; In this blog, we are going to discuss first Intent in short and then create chooser and email sending process using intent. Intent An intent is an object that provides runtime binding between seprate components (such as two activity etc). It can be used as signal to the android operating system that certain event [&hellip;]","og_url":"https:\/\/www.innovationm.com\/blog\/create-chooser-sending-email-using-intent\/","og_site_name":"InnovationM - Blog","article_published_time":"2018-06-11T10:08:22+00:00","og_image":[{"width":1123,"height":663,"url":"https:\/\/www.innovationm.com\/blog\/wp-content\/uploads\/2018\/06\/Kripa_image.png","type":"image\/png"}],"author":"InnovationM Admin","twitter_misc":{"Written by":"InnovationM Admin","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.innovationm.com\/blog\/create-chooser-sending-email-using-intent\/#article","isPartOf":{"@id":"https:\/\/www.innovationm.com\/blog\/create-chooser-sending-email-using-intent\/"},"author":{"name":"InnovationM Admin","@id":"https:\/\/www.innovationm.com\/blog\/#\/schema\/person\/a831bf4602d69d1fa452e3de0c8862ed"},"headline":"Create Chooser | Sending Email Using Intent","datePublished":"2018-06-11T10:08:22+00:00","mainEntityOfPage":{"@id":"https:\/\/www.innovationm.com\/blog\/create-chooser-sending-email-using-intent\/"},"wordCount":346,"commentCount":0,"image":{"@id":"https:\/\/www.innovationm.com\/blog\/create-chooser-sending-email-using-intent\/#primaryimage"},"thumbnailUrl":"https:\/\/www.innovationm.com\/blog\/wp-content\/uploads\/2018\/06\/Kripa_image.png","keywords":["Android"],"articleSection":["Mobile"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.innovationm.com\/blog\/create-chooser-sending-email-using-intent\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.innovationm.com\/blog\/create-chooser-sending-email-using-intent\/","url":"https:\/\/www.innovationm.com\/blog\/create-chooser-sending-email-using-intent\/","name":"Create Chooser | Sending Email Using Intent - InnovationM - Blog","isPartOf":{"@id":"https:\/\/www.innovationm.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.innovationm.com\/blog\/create-chooser-sending-email-using-intent\/#primaryimage"},"image":{"@id":"https:\/\/www.innovationm.com\/blog\/create-chooser-sending-email-using-intent\/#primaryimage"},"thumbnailUrl":"https:\/\/www.innovationm.com\/blog\/wp-content\/uploads\/2018\/06\/Kripa_image.png","datePublished":"2018-06-11T10:08:22+00:00","author":{"@id":"https:\/\/www.innovationm.com\/blog\/#\/schema\/person\/a831bf4602d69d1fa452e3de0c8862ed"},"breadcrumb":{"@id":"https:\/\/www.innovationm.com\/blog\/create-chooser-sending-email-using-intent\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.innovationm.com\/blog\/create-chooser-sending-email-using-intent\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.innovationm.com\/blog\/create-chooser-sending-email-using-intent\/#primaryimage","url":"https:\/\/www.innovationm.com\/blog\/wp-content\/uploads\/2018\/06\/Kripa_image.png","contentUrl":"https:\/\/www.innovationm.com\/blog\/wp-content\/uploads\/2018\/06\/Kripa_image.png","width":1123,"height":663},{"@type":"BreadcrumbList","@id":"https:\/\/www.innovationm.com\/blog\/create-chooser-sending-email-using-intent\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.innovationm.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Create Chooser | Sending Email Using Intent"}]},{"@type":"WebSite","@id":"https:\/\/www.innovationm.com\/blog\/#website","url":"https:\/\/www.innovationm.com\/blog\/","name":"InnovationM - Blog","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.innovationm.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.innovationm.com\/blog\/#\/schema\/person\/a831bf4602d69d1fa452e3de0c8862ed","name":"InnovationM Admin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/5c99d9eece9dfbc82297cf34ddd58e9fe05bb52fe66c8f6bf6c0a45bfb6d7629?s=96&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/5c99d9eece9dfbc82297cf34ddd58e9fe05bb52fe66c8f6bf6c0a45bfb6d7629?s=96&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/5c99d9eece9dfbc82297cf34ddd58e9fe05bb52fe66c8f6bf6c0a45bfb6d7629?s=96&r=g","caption":"InnovationM Admin"},"sameAs":["http:\/\/www.innovationm.com\/"],"url":"https:\/\/www.innovationm.com\/blog\/author\/innovationmadmin\/"}]}},"_links":{"self":[{"href":"https:\/\/www.innovationm.com\/blog\/wp-json\/wp\/v2\/posts\/4596","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.innovationm.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.innovationm.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.innovationm.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.innovationm.com\/blog\/wp-json\/wp\/v2\/comments?post=4596"}],"version-history":[{"count":0,"href":"https:\/\/www.innovationm.com\/blog\/wp-json\/wp\/v2\/posts\/4596\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.innovationm.com\/blog\/wp-json\/wp\/v2\/media\/4687"}],"wp:attachment":[{"href":"https:\/\/www.innovationm.com\/blog\/wp-json\/wp\/v2\/media?parent=4596"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.innovationm.com\/blog\/wp-json\/wp\/v2\/categories?post=4596"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.innovationm.com\/blog\/wp-json\/wp\/v2\/tags?post=4596"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}