androidandroid-activityandroid-implicit-intentexplicit-intent

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


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


Solution

  • 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