sha*_*007 5 android android-intent
我正在阅读意图和意图过滤器.我得到以下代码:
在活动中:
Intent i = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse("http://www.example.com"));
startActivity(i);
Run Code Online (Sandbox Code Playgroud)
在清单中:
<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>
Run Code Online (Sandbox Code Playgroud)
我的问题是 - 我不应该在意图内部声明android.Intent.ACTION_VIEW而不是android.content.Intent.ACTION_VIEW吗?
小智 1
android.content.Intent.ACTION_VIEWACTION_VIEW指类中常量的名称android.content.Intent。该常量的值为“android.intent.action.VIEW”。因此存在差异。