android - 无法理解 Intent 过滤器

标签 android android-intent

我正在阅读 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_VIEWandroid.content.Intent类中常量ACTION_VIEW的名称。该常量的值为“android.intent.action.VIEW”。因此存在差异。

关于android - 无法理解 Intent 过滤器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21670974/

相关文章:

android - 让未经身份验证的用户访问 FIrebase 中的数据库的缺点?

android - 如何控制 Activity 流 - 后退按钮与主页按钮

java - 是否可以将图像传输到 3 个不同的 Activity ?

android - SMS_DELIVERED Intent 的 SMS 发送报告不起作用

android如何在textview中设置超链接

android - 将自定义 View (tileview)添加到布局?

java - 将 ArrayList 内容转换为带逗号的字符串

java - 你如何通过 2 个 Activity 传递一个字符串?

java - startActivityForResult() 返回 RESULT_CANCELED

java - 在 if else 的情况下 Intent 不起作用