Intent学习1

Intent是android程序中个组件交互的一种重要方式,它不仅可以指明当前组件想要执行的动作,还可以在不同组件之间传递数据。

显示Intent,直接跳转至second活动。

Intent intent=new Intent(MainActivity.this,second.class);
startActivity(intent);

隐式Intent

在Intent中不直接指明跳转至哪个活动,而是类似于发送一个口令,系统自动找出可以识别该口令的活动供选择。

Intent intent=new Intent("com.example.activitytest.ACTION_START");
intent.addCategory("com.example.activitytest.My_CATEGORY");
startActivity(intent);

androidmaniframe设定

 <activity android:name=".second">
            <intent-filter>
                <action android:name="com.example.activitytest.ACTION_START" />
                <category android:name="android.intent.category.DEFAULT" />     //系统默认值,如果活动中不表名category则自动默认为符合
                <category android:name="com.example.activitytest.My_CATEGORY" />
            </intent-filter>
 </activity>
posted @ 2016-10-26 09:43  飞云影翼  阅读(143)  评论(0)    收藏  举报