intent的简单用法
一,跳转
显式:直接通过 intent
Intent intent = new Intent(FirstActivity.this, SecondActivity.class);
startActivity(intent);
隐式:通过代码和清单文件来完成操作
<activity android:name=".SecondActivity" >
<intent-filter>
<action android:name="com.example.activitytest.ACTION_START" />
<category android:name="com.example.activitytest.MY_CATEGORY"/>
</intent-filter>
</activity>
Intent intent = new Intent("com.example.activitytest.ACTION_START");
intent.addCategory("com.example.activitytest.MY_CATEGORY");
startActivity(intent);
二,打开webview
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("http://www.baidu.com"));
startActivity(intent);
一,跳转
显式:直接通过 intent
Intent intent = new Intent(FirstActivity.this, SecondActivity.class);
startActivity(intent);
隐式:通过代码和清单文件来完成操作
<activity android:name=".SecondActivity" >
<intent-filter>
<action android:name="com.example.activitytest.ACTION_START" />
<category android:name="com.example.activitytest.MY_CATEGORY"/>
</intent-filter>
</activity>
Intent intent = new Intent("com.example.activitytest.ACTION_START");
intent.addCategory("com.example.activitytest.MY_CATEGORY");
startActivity(intent);
二,打开webview
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("http://www.baidu.com"));
startActivity(intent);