android中显式和隐式活动调用有什么区别? [英] What is the different between Explicit and implicit activity call in android?

查看:25
本文介绍了android中显式和隐式活动调用有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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.

推荐答案

例如:

隐式活动调用

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

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>

另一种调用隐式 Intent 的方法如下:

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

显式活动调用

您拨打的电话会准确指明是哪个活动类别:

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

希望这能帮助您更多地了解 android 中的显式和隐式活动调用.

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

您可以在此处

这篇关于android中显式和隐式活动调用有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆