温馨提示:本文翻译自stackoverflow.com,查看原文请点击:其他 - What is the different between Explicit and implicit activity call in android?
android android-activity android-implicit-intent explicit-intent

其他 - Android中的Explicit和隐式活动调用有什么区别?

发布于 2020-03-28 23:41:13

android中显式和隐式活动调用之间有什么区别?如果您用一个简单的例子解释答案,那将是很好的。

查看更多

查看更多

提问者
Adham
被浏览
13
3 2020-03-11 12:13

例如:

隐式活动调用

在意图过滤器中,您可以为活动创建动作,因此其他应用可以通过此动作调用您的活动,如下所示:

<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 intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.example.com"));
startActivity(intent);

明确的活动电话

您进行呼叫以确切指示哪个活动类别:

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

希望这可以帮助您了解有关android中显式和隐式活动调用的更多信息。

您可以在此处获取有关Android Intent的更多详细信息