18

I'm confused about the difference between implicit and explicit intents. What is the purpose of implicit and explicit intents, and why are these concepts used?

I am new to Android applications, so please provide some examples.

ישו אוהב אותך
  • 28,609
  • 11
  • 78
  • 96
user1893535
  • 229
  • 1
  • 2
  • 4

2 Answers2

45

Implicit activity call

With an intent filter you create action for your activity so other apps can call your activity via an action:

<activity android:name=".BrowserActivitiy" android:label="@string/app_name">
  <intent-filter>
     <action android:name="android.intent.action.VIEW" />
     <category android:name="android.intent.category.DEFAULT" />
     <data android:scheme="http"/> 
  </intent-filter>
</activity>

.

Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.example.com"));
startActivity(intent);

Explicit activity call

You make a call that indicates exactly which activity class to use:

Intent intent = new Intent(this, ActivityABC.class);
startActivity(intent);

Here's an additional reference

ישו אוהב אותך
  • 28,609
  • 11
  • 78
  • 96
kumar_android
  • 2,273
  • 1
  • 21
  • 30
  • Is it a copy&paste form here https://stackoverflow.com/questions/10272699/what-is-the-different-between-explicit-and-implicit-activity-call-in-android/20728603? u could reference – handkock Jul 29 '19 at 00:22
29
  1. Explicit Intent: Explicit intent names the component.

  2. Implicit Intent: Implicit Intents have not specified a component.

E.g: The java class which should be called Implicit intent asked the system to perform a service without telling the system which java class should do this service.

ישו אוהב אותך
  • 28,609
  • 11
  • 78
  • 96
balaji
  • 1,555
  • 5
  • 26
  • 49