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
384
votes
21 answers

How to make a phone call using intent in Android?

I'm using the following code to make a call in Android but it is giving me security exception please help. posted_by = "111-333-222-4"; String uri = "tel:" + posted_by.trim() ; Intent intent = new Intent(Intent.ACTION_CALL); …
78
votes
9 answers

Android implicit intents VS explicit intents

Working with android I realized that implicit intents are good choice in most of cases due to their's flexibility. But what's about explicit intents? What are benefits of using them? What are common cases when it's a good practice to use them?
47
votes
8 answers

Implementing a File Picker in Android and copying the selected file to another location

I'm trying to implement a File Picker in my Android project. What I've been able to do so far is : Intent chooseFile; Intent intent; chooseFile = new Intent(Intent.ACTION_GET_CONTENT); chooseFile.setType("*/*"); intent =…
39
votes
7 answers

What is the different between Explicit and implicit activity call in android?

What is the difference between explicit and implicit activity call in android? If you explain the answer with a simple example will be good.
Adham
  • 63,550
  • 98
  • 229
  • 344
22
votes
8 answers

Pick contact directly from contact picker intent

Hello I want to pick a contact from our default contact book intent. I tried several ways to do it. Please find the code below. The problem with all those code is that they open one intermediate documents screen with few options there user has to…
14
votes
3 answers

What is the difference between queryIntentActivities() and resolveActivity().Which one is the best approach to know about existing apps for a intent?

As I can see in Android documentation when trying to build implicit intents when sending the user to another app. These are the two approaches to avoid ActivityNotFoundException. First one : Intent mapIntent = new Intent(Intent.ACTION_VIEW,…
12
votes
2 answers

Read Android intent extra data on Unity app launch

I am launching an Unity application from another Android application using a custom implicit intent. This is working fine, but I cannot figure out how to read the intent extra data in Unity? ANDROID INTENT TO LAUNCH UNITY APP i=new…
9
votes
7 answers

Call intent in Android

How can I make call by pressing button? I get my number as a string from EditText. Here is my sample code: String phone = editPhone.getText().toString(); btnPhone.setOnClickListener(new View.OnClickListener() { @Override …
user1383729
  • 111
  • 1
  • 1
  • 4
7
votes
5 answers

Android : Message Intent

I'm a beginner to android. I need to know is there any intent to open the Create Message window. I tried with this code - Intent i = new Intent(Intent.ACTION_SEND); i.setType("text/plain"); But, it raises, Gmail, Email & Message I need to raise…
Galaxy S2
  • 438
  • 1
  • 4
  • 10
7
votes
2 answers

Pick a file from an SD card using Intent

Does Android have a way to browse and pick any file from an SD card using intents? Something like: String uri = (Environment.getExternalStorageDirectory()).getAbsolutePath(); Intent i = new Intent(Intent.ACTION_PICK, Uri.parse(uri)); I am trying to…
6
votes
0 answers

Update widget on Android O

My app does not receive ACTION_SCREEN_ON or ACTION_USER_PRESENT on Android O device after device remains idle for some time. My app has widgets. I update those widgets with data from backend when the user unlocks the phone. This functionality has…
5
votes
2 answers

How can I share pdf file in android?

I try to share a pdf file from android/data/mypackage/files/file.pdf I generate these pdfs also in this app, and when I try to share it, the pdf doesn't appear in on attached files from email, or google drive says something like: "No data to…
Andrei Meriacre
  • 114
  • 1
  • 7
5
votes
1 answer

open camera with picture size as 16:9 programatically

i am developing an image editing app, when the camera is invoked i can able to change the picture size as 16:9 manually, is it possible to open the camera by setting the picture size as 16:9 programatically. the code below invokes the camera Intent…
Aravindh Kumar
  • 1,213
  • 11
  • 22
5
votes
1 answer

Does make application invisible?

I have used implicit intents in order to open my application when some one clicks on a URL in other application,I am unable to see the deployed application's icon.After deploying my aplication if i go back and try to find my application i am un able…
5
votes
2 answers

Receiving data from other apps - android

I read the documentation on receiving simple data. I want to receive an URL,i.e. text/plain from other apps. So, I declared only this intent filter:
Nikhil
  • 6,493
  • 10
  • 31
  • 68
1
2 3 4 5 6 7 8