Questions tagged [android-intent]

Questions regarding practical and advanced use of Intents, Intent Extras and Pending Intents to start an Activity, Service or to respond to a system or application event/notification via a BroadcastReceiver. (refer to info for basic familiarity)

From the Android Developers reference site:

An Intent facilitates performing late runtime binding between the code in different applications. Its most important use is in the launching of activities, where it can be thought of as the glue between activities. It is basically a passive data structure holding an abstract description of an action to be performed.

The Basics

Intents are used extensively within the Android Platform for telling the operating system that a certain action needs to be performed. At first glance, the apparent use of Intents is to start Activities (components that have a user interface). Upon gaining even a limited experience with Android development, it becomes clear that it is used for nearly every component within the Android platform.

Services are bound or started by Activities. BroadcastReceivers listen for Intents that are sent either by the operating system or other applications. Even Widgets cannot be placed onto the Home Screen without an Intent.

Intent Actions

The Action is the core of the Intent. It is simply a string that is passed to the operating system to indicate a given action. Some are general and provided directly by the platform. Others are specific to packages and unique tasks. This allows for any developer to create their own Intents with very little effort for either public or private use.

A Custom Intent Action follows the form "top.company.package.DO_SOMETHING", where: top is the top-level domain following usage conventions (com for commercial, org for non-commercial organization, edu for educational organization, etc); company is the company name of the developer; package is the name of the package; and DO_SOMETHING is a meaningful name describing the action. Android-provided Intents can be found at: Intent Filters

Example: com.softwareheroes.coolui.SHOW_LOG might show the log file for the Cool UI application made by the fictional commercial enterprise Software Heroes.

Intent Extras

Many times when starting another application component, developers will need to transmit information. The threading model can sometimes make this difficult, especially when communicating with different types of components. Intent Extras allow you to transmit a wide variety of data without having to resort to complex threading or security access levels. A full list of data types that can be transmitted and received is located here.

Pending Intents

Pending Intents are Intents that are created early to be fired later on behalf on the application that created it. Using this mechanism, an application may create an Intent to respond to a possible future event and even give that Intent to an external application. The most popularized use of these is in notifications, which require that when clicked on they perform some action.

When to Use This Tag

Since Intents are so widely used, it is hard to gauge when it might be appropriate to use this tag. In general, if you simply want to know which Intent starts which application or what the Intent is when a common system event occurs, one should refer to the reference or guide. These also link to several tutorials. If these resources do not address the specific need or query, then simply try and verify that the issue is really a lack of understanding with regard to Intents or the specific Intent.

Poor Example: How do I respond to an SMS message?

This is common knowledge and provided in the explanation of Intents on the Android Developer site.

Good Example: Can I pass the extras from Intent to another safely?

30913 questions
7
votes
1 answer

FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY isn't set for intents from history

In my activity: I use onNewIntent to handle new…
DrSergey84
  • 101
  • 1
  • 6
7
votes
1 answer

Using ConnectBot with Intents

Is there any way to access the ConnectBot functionality via intents? I want to start a ssh-session out of my application and authenticate via Private/Public Key, and close the session afterwards. Is this possible with ConnectBot and if yes, how can…
tensai
  • 105
  • 2
  • 5
7
votes
2 answers

Android: Launch Firefox from within application

just wondering if anyone know the correct intent to launch Firefox's Mobile Browser. I can't find it anywhere, so I was hoping someone here would know. Thanks
Leonidas
  • 2,110
  • 4
  • 20
  • 31
7
votes
2 answers

Open Android Camera in lower resolution with ACTION_IMAGE_CAPTURE

I am opening android camera using intent like this : Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, mCapturedImageURI); …
cagryInside
  • 790
  • 2
  • 15
  • 41
7
votes
2 answers

Intent Service never getting called

I am trying out Intent services. This is what I use to call it Button updateLocation = (Button) findViewById(R.id.btnUpdateLocation); updateLocation.setOnClickListener(new OnClickListener() { @Override public…
Sean
  • 1,123
  • 4
  • 24
  • 44
7
votes
2 answers

Get user number using intent request not working?

I am justing trying to get phone number using GetPhoneNumberHintIntentRequest to replace HintRequest. So just trying to follow google developer doc https://developers.google.com/identity/phone-number-hint/android#kotlin_2. But after following doc I…
duggu
  • 37,851
  • 12
  • 116
  • 113
7
votes
3 answers

Cannot send pending intent from widget, SendIntentException

I want to send a broadcast from my widget with this code: for (int i = 0; i < N; i++) { int appWidgetId = appWidgetIds[i]; RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget); Intent x = new Intent(); if…
Force
  • 6,312
  • 7
  • 54
  • 85
7
votes
1 answer

How do I use registerForActivityResult with StartIntentSenderForResult contract?

I am writing a Kotlin app and using Firebase for authentication. As onActivityResult is now depraceted, I am trying to migrate my app to use registerForActivityResult. I have a link to Google account feature, that starts with the Google sign-in…
7
votes
2 answers

intent filter for ical URLs

I'm trying to register my Android app as a handler for iCal URLs. To do this I set intent filters in my Manifest for the webcal:// pseudo protocol and for HTTP URLs using the text/calendar MIME type (see below). This works perfectly fine in the…
Andreas Gohr
  • 4,617
  • 5
  • 28
  • 45
7
votes
3 answers

Flutter: Intent

I try to call an Intent request from my Flutter/Android project. As described, it should be done as follows Intent intent = ​new ​Intent(); intent.setComponent(​new ​ComponentName(​"sk.co.xxx.yyy"​, "sk.co.xxx.yyy.MainActivity"​)); JSONObject jReq =…
7
votes
1 answer

How to create intent to choose image from gallery in Android 11?

I can create intent to choose image from gallery on Android in Kotlin like this: val intentGallery = Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI) if (intentGallery.resolveActivity(activity.packageManager) != null) { …
Harry
  • 323
  • 3
  • 10
7
votes
1 answer

Espresso intended is not matching my ACTION_SEND intent

I have an intent from an activity that I created like so: private fun startShareIntent() { val sendIntent = Intent().apply { action = Intent.ACTION_SEND putExtra(Intent.EXTRA_TEXT, "Watch…
Richard
  • 7,037
  • 2
  • 23
  • 76
7
votes
0 answers

How to filter the intent according to his extra data?

I got some activity that have defined intent filter like this:
Lukap
  • 31,523
  • 64
  • 157
  • 244
7
votes
2 answers

Open Android App by sending a text message?

I was wondering if it is possible to open an android app on someones phone by sending them a text message, assuming the user already has the application installed on his/her phone. Sort of like where's my Droid application? Could I send it like a…
IZI_Shadow_IZI
  • 1,921
  • 4
  • 30
  • 59
7
votes
2 answers

Is there a way to flush DNS cache on Android?

I'd like to flush DNS in my Android app due to some external event. I've noticed that Android system code uses something like this: final Intent intent = new Intent(Intent.ACTION_CLEAR_DNS_CACHE); to clear DNS cache but it doesn't appear to be…
alexbtr
  • 3,292
  • 2
  • 13
  • 25
1 2 3
99
100