Questions tagged [android-implicit-intent]

An implicit intent specifies an action that can invoke any app on the device able to perform the action. Using an implicit intent is useful when your app cannot perform the action, but other apps probably can and you'd like the user to pick which app to use.

From the official Android documentation :

An implicit intent specifies an action that can invoke any app on the device able to perform the action. Using an implicit intent is useful when your app cannot perform the action, but other apps probably can and you'd like the user to pick which app to use.

For example, if you have content you want the user to share with other people, create an intent with the ACTION_SEND action and add extras that specify the content to share. When you call startActivity() with that intent, the user can pick an app through which to share the content.

Caution: It's possible that a user won't have any apps that handle the implicit intent you send to startActivity(). If that happens, the call will fail and your app will crash. To verify that an activity will receive the intent, call resolveActivity() on your Intent object. If the result is non-null, then there is at least one app that can handle the intent and it's safe to call startActivity(). If the result is null, you should not use the intent and, if possible, you should disable the feature that issues the intent.

// Create the text message with a string
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, textMessage);
sendIntent.setType(HTTP.PLAIN_TEXT_TYPE); // "text/plain" MIME type

// Verify that the intent will resolve to an activity
if (sendIntent.resolveActivity(getPackageManager()) != null) {
    startActivity(sendIntent);
}

Note: In this case, a URI is not used, but the intent's data type is declared to specify the content carried by the extras.

When startActivity() is called, the system examines all of the installed apps to determine which ones can handle this kind of intent (an intent with the ACTION_SEND action and that carries "text/plain" data). If there's only one app that can handle it, that app opens immediately and is given the intent. If multiple activities accept the intent, the system displays a dialog so the user can pick which app to use.

106 questions
2
votes
1 answer

How to restart foreground service after app updating in Android Oreo?

We need the foreground service of our application to be restarted after the application is automatically updated from Google Play. For SDK < 26 we registered the receiver on PACKAGE_REPLACED actoin and everything worked fine. How can we do the same…
2
votes
1 answer

How do I use NoteIntents?

I am trying to access NoteIntents.CREATE_NOTE. But neither does Android Studio recognize it nor does it let me import com.google.android.gsm.actions.NoteIntents; I am trying to create an implicit intent receiver for creating notes. I have been…
2
votes
3 answers

No apps can perform this action

When I am trying to invoke implicit intent with action "Intent.ACTION_GET_CONTENT", I am getting this error alert "No apps can perform this action." Thanks in advance. Please see my code below. Intent intent = new Intent(); intent.setType("*/*"); …
Dhruvi
  • 1,971
  • 2
  • 10
  • 18
2
votes
3 answers

Android get URI of cropped image from Intent

I'm trying to capture an image from the Android Camera/ Pick an image from the gallery and then crop it before performing other operations on it. I'm having trouble with getting back the URI of the cropped image. Any help on how to get back the URI…
2
votes
1 answer

android implicit intent edit failed to load image

This is my implicit intent to invoke image editing apps on the device: startActivity(new Intent(Intent.ACTION_EDIT).setDataAndType(myUri, getMimeType(myUri)).setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | …
Eftekhari
  • 1,001
  • 1
  • 19
  • 37
2
votes
1 answer

How does Android different between multiple components that have same action and category?

I looked up intent filters and found that they will be used when "Android finds the appropriate component to start by comparing the contents of the intent to the intent filters declared in the manifest file of other apps on the…
committedandroider
  • 8,711
  • 14
  • 71
  • 126
2
votes
1 answer

Android ACTION_PICK phone number of specific contact

I know how to create an intent to let the contacts app display a specific contact: Intent intent = new Intent(Intent.ACTION_VIEW); Uri uri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_LOOKUP_URI,…
Brabbeldas
  • 1,939
  • 4
  • 20
  • 32
1
vote
1 answer

Consider adding a `` declaration to your manifest when calling this \method;

I am getting this warning on resolveActivity line while using implicit intents and I am unable to open any website because of that. btnWeb.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View…
1
vote
1 answer

Why does Unexpected implicit cast to `EditText`: layout tag was `TextView`

I have a problem, I'm trying to finish the lesson Android fundamentals 02.3: Implicit intents, but there are some errors the first one is Unexpected implicit cast to EditText: layout tag was TextView the second one is Consider adding a declaration…
Agung kusuma
  • 49
  • 1
  • 5
1
vote
2 answers

How to send message to facebook

String url ="https://m.facebook.com/messages/read/?fbid=101631428274763"; Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); startActivity(intent); I want to directly send some messages. This way I am able to send message to fb…
1
vote
0 answers

How to set an Instagram story like spotify In Android?(I want to share image with app url as story)

I want to share an Image with my app link as an Instagram story when the user clicks on that link it's should redirect to my app. from Spotify app it's possible but I'm not able to do this. from the below code I can show the only image but I need to…
1
vote
1 answer

My app needs to store an image on SD card to share on Facebook News Feed

I am trying to share an image through implicit intent. The image is shared successfully through Messenger and Twitter but fails on Facebook News Feed, Viber and Email. I read somewhere that I need to save the image to the external or internal SD…
Maz
  • 118
  • 10
1
vote
1 answer

How to Access Default Apps, having no application id?

I am learning Implicit Intents. I am making an app to cover most of the implicit intent concepts, ScreenShot of this app is here. In this App, I want to get access to device default Weather and Radio applications. But the problem is these two apps…
1
vote
1 answer

How can i use implicit intent but avoid "select an app to handle this intent" screen?

In my code I want to trigger an implicit intent to open another android library activity. Intent i = new Intent("Shared library", Uri.parse("https://www.google.com/")); startActivity(i); Lets say few apps contain this same library. If I trigger an…
1
vote
1 answer

Wrong activity displayed when implicit intent received from another app with Action.SEND

I have an app with two activities: MainActivity, which contains a URL entry field where the user can enter a YouTube video URL and press a submit button, to start the second activity, VideoActivity, which displays some information about this video…