android-intent Getting started with android-intent

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!

Remarks

Types of Intents

  1. Explicit Intents
  2. Implicit Intents

Explicit intent: going to be connected internal world of application, suppose you want to connect one activity to another activity, this can be done by explicit intent. Below is the code snippet demonstrating the connection between first and second activity:

// Explicit Intent by specifying its class name
Intent intent_activity = new Intent(FirstActivity.this, SecondActivity.class);

// Starts TargetActivity
startActivity(intent_activity);

Implicit Intents: these intents do not name a target and the field for target component name is left blank. Implicit intents are often used to activate components in other applications. For example:

Intent intent_message= new Intent(Intent.ACTION_SEND); 
intent_message.setData(Uri.fromFile(fileToShare));
startActivity(intent_message);  

Installation or Setup

Detailed instructions on getting android-intent set up or installed.

Start another activity - Hello World of intents

public class CurrentActivity extends AppCompatActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.current_activity);
        
        Intent intent = new Intent(this, DestinationActivity.class);
        startActivity(intent);
    }
}
 


Got any android-intent Question?