我正在阅读 Intent 和 Intent 过滤器。我得到以下代码:
Activity 中:
Intent i = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse("http://www.example.com"));
startActivity(i);
在 list 中:
<activity android:name="com.example.intentdemo.CustomActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="com.example.intentdemo.LAUNCH" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="http" />
</intent-filter>
</activity>
我的问题是 - 我不应该在 Intent 中声明 android.Intent.ACTION_VIEW 而不是 android.content.Intent.ACTION_VIEW 吗?
最佳答案
android.content.Intent.ACTION_VIEW
指android.content.Intent
类中常量ACTION_VIEW
的名称。该常量的值为“android.intent.action.VIEW”。因此存在差异。
关于android - 无法理解 Intent 过滤器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21670974/