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

Track a phone call duration

Is it possible to utilize the users phone through their cell provider, and track the length of a phone call? So the user presses a button in the app "Call Now". A call begins to a pre-determined number. We record the start time. When the call ends,…
spentak
  • 4,627
  • 15
  • 62
  • 90
7
votes
2 answers

Taking picture and geotag it

I should make an app to take a picture and geotag it. I see 2 ways to do it: Using an intent for the android camera default, take the picture (meanwhile looking for GPS location), and then edit EXIF header; Build a camera application through the…
KitKat
  • 715
  • 2
  • 7
  • 10
7
votes
5 answers

android pass bundle with search

Hello i am using android 3.0 search widget(not the search mode), the problem is i need to pass some parameters along with the search word. Android isn't calling any of these searchManager.setOnDismissListener( new OnDismissListener() { …
max4ever
  • 11,909
  • 13
  • 77
  • 115
7
votes
5 answers

Android: stopService in another Activity

How can I stop my Service in another Activity? I start the service in my summaryActivity SocketServiceIntent = new Intent(this, SocketService.class); SocketServiceIntent.putExtra("MessageParcelable", mp); startService(SocketServiceIntent); And…
user1263776
  • 73
  • 1
  • 1
  • 3
7
votes
2 answers

How do you receive outgoing call in broadcastreceiver

I am trying to identify and transfer to an activity after an outgoing call is initiated. I used ACTION_NEW_OUTGOING_CALL in the Intent filter. However how csn I identify that the call is outgoing. I did this for an incoming call (as seen below) but…
user1163234
  • 2,407
  • 6
  • 35
  • 63
7
votes
2 answers

Android 4.0.3 and finish activity

I have and Activity A calling Activity B. Then Activity B dials a number and then on the IDLE-OFFHOOK- IDLE state I call ActivityB.this.finish() so that activity A shows on front. This all worked fine from Android 2.3.x till version 4.0. Now it…
7
votes
4 answers

Verify Twitter app is logged in on Android

My app I'm developing launches the official twitter app new post screen so the user can post a tweet with some extra text added in the intent. I have got this working nicely however things get a little confused if the user is not logged in with the…
W0lf7
  • 729
  • 1
  • 8
  • 15
7
votes
3 answers

Error-proof way of starting SMS intent in Android

In my Android application, I use the following code to start the messaging app and fill in a default text for a text message: Intent intent = new…
caw
  • 30,999
  • 61
  • 181
  • 291
7
votes
2 answers

Change widget visibility on click

My widget consists two relative layouts. I have made both the layouts clickable. Following are the id's of the layout: android:id="@+id/upper_layout" android:id="@+id/bottom_layout" Now, what I need is that if a user clicks on the upper_layout,…
curiousguy
  • 609
  • 3
  • 13
7
votes
2 answers

Why is resultCode = -1 here after StartActivityForResult?

Everything works fine, EXCEPT that this activity gives resultCode = -1 public class SetTimeDialog extends Activity{ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); …
Tombola
  • 1,131
  • 5
  • 15
  • 26
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
3 answers

Passing Data from Broadcast Receiver to another Activity

Hi I've been having an issue with Broadcast Receivers and passing information to another activity. I'm trying to create an application that will capture incoming SMS messages, look for a website in the text, then pop up an Alert Dialog box asking if…
Doug
  • 77
  • 1
  • 1
  • 6
7
votes
1 answer

how to transfer extra data from one fragment to another through activity

For example, In a list view hosted by ListActivity, when user click on a item on the list, a new activity will be launched, and previous activity transfer extra data to the new activity like below: public class Notepadv2 extends ListActivity { …
Leem.fin
  • 40,781
  • 83
  • 202
  • 354
7
votes
5 answers

Starting navigation in Waze with Android's Intents

I have a simple Android app which should be able to allow navigation between 2 GeoPoint's. I can easily display a GeoPoint on Waze, writing this small piece of code: String uri = "waze://?ll=40.761043, -73.980545&z=10"; startActivity(new…
ofirbt
  • 1,846
  • 7
  • 26
  • 41
7
votes
4 answers

How do I retrieve a picasa photo from a built-in gallery?

I want to retrieve the photos from built-in Android gallery calling ACTION_PICK Intent. I have a problem with Picasa's images. I have used the code to this link, but it don't work (the File object don't exist). Any idea, please.
Michel Foucault
  • 1,724
  • 3
  • 25
  • 48
1 2 3
99
100