What is the difference between explicit and implicit activity call in android? If you explain the answer with a simple example will be good.
Activity is a UI component which you see on your screen. An Intent is a message object which is used to request an action from the same/different app component.
There are two intents available in android as Implicit Intents and Explicit Intents.
An intent filter declares the capabilities of its parent component — what an activity or service can do and what types of broadcasts a receiver can handle. It opens the component to receiving intents of the advertised type, while filtering out those that are not meaningful for the component.
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
An explicit intent is always delivered to its target, no matter what it contains; the filter is not consulted. But an implicit intent is delivered to a component only if it can pass through one of the component's filters
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With