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
8
votes
1 answer

animated transition between an activity and another

I state that i'm not very experienced in android, and I would like to understand, perhaps with some tutorial, how to implement any scrolling animation between one activity and another. I hope in your help
user1480020
  • 143
  • 1
  • 3
  • 10
8
votes
2 answers

Change intent bundle data before an activity is re-created after orientation change

I have a notification that starts my activity and passes a messages using the intent's putExtra() function. The message is then displayed to the user in the activity's onCreate function. When the application is restarted due to a orientation…
None
8
votes
2 answers

Android Google Play intent referrer

I'm launching Google Play like this: Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=com.example")); intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY |…
8
votes
2 answers

How to make an basic Android USB Host application?

I'm trying to develop a application which detects a USB device and shows a pop-up when it's connected. I followed the basic USB tutorial that you can find in Android Developers website…
Machado
  • 14,105
  • 13
  • 56
  • 97
8
votes
1 answer

Playing youtube video in Android app

In my Android app I'd like the user to tap an image once, have a youtube video play automatically and when the video is done the user is immediately returned to the app. What's the best way to do this in Android? I tried using intents. This works in…
SundayMonday
  • 19,147
  • 29
  • 100
  • 154
8
votes
2 answers

Activity return a image

I want to return a bitmap in my activity, so other applications can use it. Returning a text is clear. Intent data = new Intent(); data.putExtra("text1", "text."); data.putExtra("text2", "longer text."); setResult(RESULT_OK, data); But how to…
beewhale
  • 93
  • 1
  • 4
8
votes
2 answers

Specifying a SEND (sharing) intent filter for a Service

I am trying to filter and handle intents with android.intent.action.SEND actions in one of my Services. I wrote the following in my AndroidManifest.xml:
8
votes
3 answers

Showing a marker at a geo:-url in Android Maps

Is it possible not only to have Google Maps on Android show a given coordinate in the Maps Application but have also a marker (or pin) set at the location? I read the documentation at https://developer.android.com/guide/appendix/g-app-intents.html…
Dirk Jäckel
  • 2,979
  • 3
  • 29
  • 47
8
votes
3 answers

NullPointerException from getExtras()

I'm creating an intent to transfer data from one activity to another like this : Intent intent = new Intent(this, ActivityHighScore.class); intent.putExtra("USERNAME", username); intent.putExtra("PLAYERMOVES", playerMoves); …
Ben
  • 319
  • 2
  • 5
  • 7
8
votes
2 answers

Android: Looping through a string array - help needed on logic for intent method

I'm a java novice and I've using the code below to display a list of clickable TextViews that call a specific class when they are clicked. It is a list of football team names. Eg. Arsenal Manchester United Chelsea Clicking on TextView Arsenal…
tiptopjat
  • 499
  • 3
  • 13
  • 24
8
votes
1 answer

Samsung My Files explorer: Pick file Intent

I would like to start an intentchooser which can return any kind of file. The following code works with the usual file explorers (ES, Astro, etc.) but not with the built-in samsung My Files explorer. Intent selectFile = new…
steliosf
  • 3,669
  • 2
  • 31
  • 45
8
votes
6 answers

Open the native browser from an android app

I have an android phone with multiple browsers installed and I might or might not set a browser to default. So, my question is.. From my App, How do I force open a link only in the NATIVE android browser? Is there a way I can know if there is a…
defactodeity
  • 714
  • 1
  • 8
  • 21
8
votes
2 answers

View or Fragment library to compose UI for common data types

Problem Reusables@common.com £1,000,000 www.inventing-a-wheel.ee Action Shortcut: C I need to let the user enter an email, pick a date, edit a webpage, choose an image etc - there are a number of common presentation tasks that are not directly…
Cel
  • 6,467
  • 8
  • 75
  • 110
8
votes
3 answers

debugging app when launched by intent filter

I normally debug my apps by pressing the little "bug" icon in Eclipse. But now I have inserted an intent filter like this in my manifest: While the app launches now…
user387184
  • 10,953
  • 12
  • 77
  • 147
8
votes
3 answers

Android onActivityResult called early

I have 2 Activities, each in seperate applications. Activity1 has a button the user can click and it calls the second activity using an intent in its onClick() method: Intent myIntent =…
user1205577
  • 2,388
  • 9
  • 35
  • 47