Tuesday, 1 September 2015

Android Intents

Android Intent is the message that is passed between components such as activities, content providers, broadcast receivers, services etc.
It is generally used with startActivity() method to invoke activity, broadcast receivers etc.
The dictionary meaning of intent is intention or purpose. So, it can be described as the intention to do action.
The LabeledIntent is the subclass of android.content.Intent class.
Android intents are mainly used to:

  • Start the service
  • Launch an activity
  • Display a web page
  • Display a list of contacts
  • Broadcast a message
  • Dial a phone call etc.
Types of Intents In Android
1. Explicit Intent
2. Implicit Intent
3. Sticky Intent
4. Pending Intent
5. Intent Filter
Developers are Mostly Using Two Primary Intents
1. Explicit Intent
2. Implicit Intent

 Explicit Intent  
specifies the component. In such case, intent provides the external class to be invoked.

Navigation Between the Two Activities  is Called Explicit Intent

Syntax:-
Intent  in=new Intent(Currentclass.this,TargetActivity.class);
startActivity(in);

Implicit Intent 
doesn't specifiy the component. In such case, intent provides information of available components provided by the system that is to be invoked.

it's calling webpage is called Implicit Intent
Syntax:-
Intent  in=new Intent(Intent.ACTION_VIEW,
Uri.parse("http://www.google.com"));
 startActivity(in);






No comments:

Post a Comment