Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
  • Intent and its type in android.

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 121
    Comment on it

    Intent:- Intent is a message object that passed between android components such as broadcast receiver, services, activity, content providers etc. Android provide facilities to communicate between components using intent in several ways, there are three important cases.

    1. Start the Activity
    2. Start the Services
    3. Delivered the BroadCast Receiver message

    Intent Types:- There are two type of intent in android.

    1- Implicit Intent: Implicit intent doesn't specify any components( such as service, activity and any broadcast receiver). In such case, intent provides only information of available components provide by Android system to be invoked.


    String url="";
    Intent intent=new Intent(Intent.ACTION_VIEW,Uri.parse(url));

    As you can see, there did not provided any components with intents.

    2- Explicit Intent:  Explicit Intent specifies the components that is which class to be invoked. We pass one components to fire intent and another components to be invoked.

    Explicit intent example to start one activity from another Activity:

    Intent i = new Intent(ActivityA.this, ActivityB.class);

    Explicit intent example to start one activity from another Activity with data:

    Intent i = new Intent(ActivityA.this, ActivityB.class);
    intent.putExtra("Value","Welcome to ActivityB");

    How to use Implicit Intent for one application to another application:

    Implicit intent specifies an action that invoke by any application which is on device and is able to handle that action. Implicit intent is useful when your app cant perform the action, but there are some other apps on the device which can perform that action and user can pic which app to use.

    Example: If you want share some contents with other users, then create an implicit intent with the Action_Send action and add extras specify data. User call start activity then you can pic the app which are applicable to perform this action .

    // Create the text message with a string 
    Intent sendIntent = new Intent(); 
    sendIntent.putExtra(Intent.EXTRA_TEXT, textMessage);


 0 Comment(s)

Sign In

Sign up using

Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: