Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between implicit and explicit intents [duplicate]

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.

like image 868
user1893535 Avatar asked Dec 11 '12 04:12

user1893535


People also ask

What are intents what are the uses of intents explain explicit and implicit intents?

Each intent filter specifies the type of intents it accepts based on the intent's action, data, and category. The system delivers an implicit intent to your app component only if the intent can pass through one of your intent filters.

What is the difference between activity and intent?

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.

What is not specified by implicit intent?

Implicit Intent doesn't specifiy the component. In such case, intent provides information of available components provided by the system that is to be invoked.

What is intent explain implicit intent with an example application?

In android, Implicit Intents won't specify any name of the component to start instead, it declare an action to perform and it allows a component from other apps to handle it. For example, by using implicit intents we can request another app to show the location details of the user or etc.


1 Answers

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

like image 61
kumar_android Avatar answered Oct 14 '22 14:10

kumar_android