首页 > 其他 > 详细

Intent_显式与隐式

时间:2016-08-17 01:31:27      阅读:186      评论:0      收藏:0      [点我收藏+]

所谓的显示intent就是我们常用的Intent.setclass(xxx.this,xxx.class)等

 

隐式Intent则是可以直接通过androidMainfest中的<intent-filter> 启动activity

        <activity android:name=".Intent1_test">
            <intent-filter>
                <category android:name="android.intent.category.DEFAULT"></category>

                <action android:name="Intent1"></action>
            </intent-filter>
        </activity>


启动时候,也可以用一个静态常量来表示

startActivity(new Intent("Intent1"));

//或者
startActivity(new Intent(Intent1_test.ACTION));//Intent1_test为activity的名,ACTION为常量:public static final String ACTION = "Intent1";

 

隐式Intent更重要的还是可以启动别的APP的活动页面,只需要将Intent1改为对应的名称即可

startActivity(new Intent("Intent1"));


关于名字的命名法也是有  包名 +intent.action + activity名

 

如果你要明确拒绝被别的app启动某一个活动,需要在mainFest的活动标签中写明exported="false"

        <activity android:name=".Intent1_test" android:exported="false">
            <intent-filter>
                <category android:name="android.intent.category.DEFAULT"></category>

                <action android:name="Intent1"></action>
            </intent-filter>

 

Intent_显式与隐式

原文:http://www.cnblogs.com/lyxin/p/5778370.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!