Warm tip: This article is reproduced from stackoverflow.com, please click
android android-activity android-implicit-intent explicit-intent

What is the different between Explicit and implicit activity call in android?

发布于 2020-03-28 23:17:29

What is the difference between explicit and implicit activity call in android? If you explain the answer with a simple example will be good.

Questioner
Adham
Viewed
16
3 2020-03-11 12:13

For example:

implicit activity call

In intent filter you create action for you activity, so other app can call your activity via this action as following:

<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>

And the other way to call implicit Intent is below:

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

Explicit activity call

You make a call that indicate exactly which activity class:

Intent intent = new Intent(this, ActivityABC.class);
intent.putExtra("Value", "This value for ActivityABC");
startActivity(intent);

Hope this help you understand more about Explicit and implicit activity call in android.

You can get more detail about Android Intent here