{"id":6012,"date":"2025-09-17T22:35:44","date_gmt":"2025-09-18T03:35:44","guid":{"rendered":"https:\/\/www.incredigeek.com\/home\/?p=6012"},"modified":"2025-09-17T22:37:18","modified_gmt":"2025-09-18T03:37:18","slug":"how-to-receive-an-implicit-intent-for-android-app","status":"publish","type":"post","link":"https:\/\/www.incredigeek.com\/home\/how-to-receive-an-implicit-intent-for-android-app\/","title":{"rendered":"How to receive an Implicit Intent in an Android App"},"content":{"rendered":"\n<p>The goal is to be able to display text in our Main Activity from an implicit intent via the share feature in Android.<\/p>\n\n\n\n<p>Steps:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Modify the Android Manifest to receive an implicit intent.<\/li>\n\n\n\n<li>Setup Main Activity to display received text.<\/li>\n<\/ol>\n\n\n\n<p><em>These steps assume you have at least a basic project set up in Android Studio.<\/em><\/p>\n\n\n\n<p>Helpful links:<\/p>\n\n\n\n<p><a href=\"https:\/\/developer.android.com\/guide\/components\/intents-filters#Receiving\">https:\/\/developer.android.com\/guide\/components\/intents-filters<\/a><\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Modify the Android Manifest to receive an implicit intent <\/h2>\n\n\n\n<p>We will need to <strong>add<\/strong> the following to the <code>&lt;intent-filter&gt;<\/code> section of our Main Activity.  <\/p>\n\n\n\n<pre class=\"wp-block-code has-dark-gray-background-color has-background\"><code class=\"\">&lt;action android:name=\"android.intent.action.SEND\"\n&lt;category android:name=\"android.intent.category.DEFAULT\" \/&gt;\n&lt;data android:mimeType=\"text\/plain\"\/&gt;<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p>A helpful note from the page <a href=\"https:\/\/developer.android.com\/guide\/components\/intents-filters#Receiving\">Android Developer page<\/a>:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p><strong>Note:<\/strong>&nbsp;To receive implicit intents, you&nbsp;<em>must include<\/em>&nbsp;the&nbsp;<code><a href=\"https:\/\/developer.android.com\/reference\/android\/content\/Intent#CATEGORY_DEFAULT\">CATEGORY_DEFAULT<\/a><\/code>&nbsp;category in the intent filter. The methods&nbsp;<code><a href=\"https:\/\/developer.android.com\/reference\/android\/app\/Activity#startActivity(android.content.Intent)\">startActivity()<\/a><\/code>&nbsp;and&nbsp;<code><a href=\"https:\/\/developer.android.com\/reference\/android\/app\/Activity#startActivityForResult(android.content.Intent,%20int)\">startActivityForResult()<\/a><\/code>&nbsp;treat all intents as if they declared the&nbsp;<code><a href=\"https:\/\/developer.android.com\/reference\/android\/content\/Intent#CATEGORY_DEFAULT\">CATEGORY_DEFAULT<\/a><\/code>&nbsp;category. If you do not declare this category in your intent filter, no implicit intents will resolve to your activity.<\/p>\n<\/blockquote>\n\n\n\n<p>This means by default, we can not receive an implicit intent to the MainActivity in an Android app, unless we add the <code>DEFAULT<\/code> category.  <\/p>\n\n\n\n<p>Our app should now show up in the Android Share menu when you select some text and hit &#8220;Share&#8221;.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.incredigeek.com\/home\/wp-content\/uploads\/2025\/09\/MyApp.png\"><img loading=\"lazy\" decoding=\"async\" width=\"377\" height=\"329\" src=\"https:\/\/www.incredigeek.com\/home\/wp-content\/uploads\/2025\/09\/MyApp.png\" alt=\"\" class=\"wp-image-6014\" srcset=\"https:\/\/www.incredigeek.com\/home\/wp-content\/uploads\/2025\/09\/MyApp.png 377w, https:\/\/www.incredigeek.com\/home\/wp-content\/uploads\/2025\/09\/MyApp-300x262.png 300w, https:\/\/www.incredigeek.com\/home\/wp-content\/uploads\/2025\/09\/MyApp-344x300.png 344w\" sizes=\"auto, (max-width: 377px) 100vw, 377px\" \/><\/a><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Setup Main Activity to display received text<\/h2>\n\n\n\n<p>Now that we can send text to our app, we should do something with it.<\/p>\n\n\n\n<p>In our Main Activity we have a Text View that we will update.  Change <code>myTextView<\/code> to your Text View id.<\/p>\n\n\n\n<pre class=\"wp-block-code has-dark-gray-background-color has-background\"><code class=\"\">val myText: TextView = findViewById(R.id.myTextView)\nmyText.text = intent.getStringExtra(Intent.EXTRA_TEXT)<\/code><\/pre>\n\n\n\n<p>Now if we share some text and send it to our app, it updates the Text View with our selected text.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.incredigeek.com\/home\/wp-content\/uploads\/2025\/09\/image-1.png\"><img loading=\"lazy\" decoding=\"async\" width=\"377\" height=\"329\" src=\"https:\/\/www.incredigeek.com\/home\/wp-content\/uploads\/2025\/09\/image-1.png\" alt=\"\" class=\"wp-image-6015\" srcset=\"https:\/\/www.incredigeek.com\/home\/wp-content\/uploads\/2025\/09\/image-1.png 377w, https:\/\/www.incredigeek.com\/home\/wp-content\/uploads\/2025\/09\/image-1-300x262.png 300w, https:\/\/www.incredigeek.com\/home\/wp-content\/uploads\/2025\/09\/image-1-344x300.png 344w\" sizes=\"auto, (max-width: 377px) 100vw, 377px\" \/><\/a><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The goal is to be able to display text in our Main Activity from an implicit intent via the share feature in Android. Steps: These steps assume you have at least a basic project set up in Android Studio. Helpful &hellip; <a href=\"https:\/\/www.incredigeek.com\/home\/how-to-receive-an-implicit-intent-for-android-app\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[540,792],"tags":[541,1734,1733,606,615],"class_list":["post-6012","post","type-post","status-publish","format-standard","hentry","category-android","category-programming","tag-android","tag-implicit-intents","tag-intents","tag-programming","tag-share"],"_links":{"self":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts\/6012","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/comments?post=6012"}],"version-history":[{"count":4,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts\/6012\/revisions"}],"predecessor-version":[{"id":6019,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts\/6012\/revisions\/6019"}],"wp:attachment":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/media?parent=6012"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/categories?post=6012"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/tags?post=6012"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}