top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

What is intents in android and what are the types of it? Examples would be helpful?

+1 vote
399 views
What is intents in android and what are the types of it? Examples would be helpful?
posted Mar 5, 2016 by Mary D'souza

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote
 
Best answer

Intent is a class which extends Object and the dictionary meaning of intent is intention or purpose. So, it can be described as the intention to do action."Intents are description of operation(message Object) to be perform."see this example

Intent  intent=new Intent(FirstActivity.this,SecondActivity.class);

its most significant 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.
Android intents are mainly used to:
Start the service
Launch an activity
Display a web page
Display a list of contacts
Broadcast a message

Two types of intent are there
implicit intent and explicit intent
where implicit intent: intent provides information of available components provided by the system that is to be invoked.Example-

Intent intent=new Intent(Intent.ACTION_VIEW);  
intent.setData(Uri.parse("http://tech.queryhome.com"));  
startActivity(intent);

and Explicit intent: it provides details of class which is to be invoked.Example-

 Intent  intent=new Intent(FirstActivity.this,SecondActivity.class);

Reference:1. http://developer.android.com/reference/android/content/Intent.html
2. http://www.javatpoint.com/android-intent-tutorial

answer Mar 5, 2016 by Shivam Kumar Pandey
thanks @Mary D
Thanks for the answer
That time I was started learning android programming.
Now it is not my cup of tea
...