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
3 answers

Add Images on Canvas with Android

I'm new to android java and I don't really knows how to make the button appear on my VIEW after a long time researching online. I can see my button in the layout but not on my view when I debug it.I'm not sure how to put more than one images in…
ping
  • 133
  • 1
  • 1
  • 7
8
votes
6 answers

Passing ArrayList Between multiple Activities

I am trying to pass an ArrayList of Objects between multiple activities in my application. Is it possible to do this using an Intent using the setData() method?
Javacadabra
  • 5,578
  • 15
  • 84
  • 152
8
votes
2 answers

How to update Sqlite database for only one column using WHERE clause in android

Possible Duplicate: SQLite in Android How to update a specific row Is it possible to update database for one column using where statment And this was my table structure and i need to update "messagestatus" column using "id". db.execSQL("CREATE…
Vishnu
  • 349
  • 3
  • 8
  • 16
8
votes
4 answers

Android: ShareActionProvider with no history

According to the Android documentation if I don't want my ShareActionProvider to persist the share history I should call mShareActionProvider.setShareHistoryFileName(null) However when I do this I get the following crash on selecting a share…
8
votes
3 answers

Get data from another activity

Still working on my skills in android. My problem here is that i have a label from my database that contain a name that is in a spinner, when i click on the label, a dialog comes and give you three choices: 1. update. 2. delete. 3. cancel. I got…
Tayseer
  • 491
  • 1
  • 5
  • 16
8
votes
1 answer

MediaPlayer in separate thread using Service or IntentService

Hi I need a MediaPlayer instance to run in background so I started using a Service. Everything works fine but I get ANR (application not responding) after a while, even if the UI works perfectly. Fair enough, I do know Services are still running on…
Lele
  • 281
  • 3
  • 13
8
votes
2 answers

Android Send Intent attaching photo from sdcard as 0 length file

I know a variant of this question was asked before trying-to-attach-a-file-from-sd-card-to-email But the solution offered, i.e. a reboot doesn't seem to do it for me. I have seen a good number of group postings which support this being a problem. …
Finlay
  • 161
  • 1
  • 4
  • 7
8
votes
2 answers

Android Intent :-Use Intent to pass class objects from Activities

Possible Duplicate: How to send an object from one Android Activity to another using Intents? I want to pass a class object from an Activity to other when one Activity calls to the other. I am trying to use Intent.putExtra(name, value) to make…
Iban Arriola
  • 2,526
  • 9
  • 41
  • 88
8
votes
3 answers

Check user action on Intent.ACTION_VIEW

I have a listview populated with some files,there can be various types like pdf or documents.When a user clicks on one i get the file mime type and start an intent that let's the user choose which application to use to open that file.What i want is…
sokie
  • 1,966
  • 22
  • 37
8
votes
1 answer

How to change "Choose an action" to "Complete action using" on Android?

I have an an NFC app which allow user to scan their NFC tags and perform some action. I faced an issue which is when user scanned the tag, it will how "Choose an action" but not "Complete action using". The different between these two is, "Complete…
Jason
  • 878
  • 2
  • 9
  • 21
8
votes
5 answers

Intent and Parcelable object Android

Why do I need to parcel my object even if I just need to send it to another thread of the same task? Actually I need to open an activity that will run even on the same thread (the main thread). In other words why didn't Google provide a version of…
user1175011
8
votes
4 answers

"take a picture and present it" in portrait mode on Samsung Galaxy S

I am trying to simply take a picture and present it in an ImageView with my samsung galaxy s. it's working fine when I do it on landscape but not on portrait. I am not getting any error or exception - just not getting anything... There is a lot of…
yehudahs
  • 2,488
  • 8
  • 34
  • 54
8
votes
3 answers

How to pass JSON Object to new activity

I have an application that needs to download JSON from URL using AsyncTask and on onPostExecute() pass that JSON Object to next Activity using putExtra method, but I'm constantly getting an error,which reads "putExtra can only be used to pass…
Silvio Marijic
  • 483
  • 4
  • 12
  • 22
8
votes
2 answers

how to launch Activity with FLAG_REORDER_TO_FRONT and FLAG_CLEAR_TOP

I have four activity in my tasks A,B,C,D. Activities are launched in order A->B->C->D. Here, I want to go back to the activity A from D and resume that activity . So that i used the intent flag …
Muthuraj
  • 447
  • 1
  • 5
  • 18
8
votes
2 answers

How to set up my personal keyboard as standard input in my app

I created a small keyboard to replace the standard Android keyboard. What should I do to set my keyboard as standard input in my app? Thanks
David
  • 253
  • 4
  • 13