zoukankan      html  css  js  c++  java
  • implicit intent的声明和使用

    在guide/topics/intents/intents-filters.html里有这一段:
    In principle, therefore, an Intent object with no categories should always pass this test, regardless of what's in the filter. That's mostly true.

    However, with one exception, Android treats all implicit intents passed to startActivity() as if they contained at least one category: "android.intent.category.DEFAULT" (the CATEGORY_DEFAULT constant). Therefore, activities that are willing to receive implicit intents must include "android.intent.category.DEFAULT" in their intent filters.


    (Filters with "android.intent.action.MAIN" and "android.intent.category.LAUNCHER" settings are the exception. They mark activities that begin new tasks and that are represented on the launcher screen. They can include "android.intent.category.DEFAULT" in the list of categories, but don't need to.) See Using intent matching, later, for more on these filters.)

    所有愿意接受隐形Intent的组件都必须将该action包含在android.intent.category.DEFAULT的的类别下,因为startActivity默认将该Intent的动作包含在该类别里。
    如“被呼叫方”可以添加这样的项:
                 <intent-filter>
                    <action android:name="com.logansoft.testpia.TESTPIA" />
                    <category android:name="android.intent.category.DEFAULT" />
                </intent-filter>                  
    而“呼叫方”可以启动它:
            Intent intent = new Intent();
            intent.setAction("com.logansoft.testpia.TESTPIA");
            startActivity(intent);


  • 相关阅读:
    *VC编程规范
    C++的va_start() va_end()函数应用(转)
    * C++类的分解,抽象类与纯虚函数的需要性
    *C++中的回调
    *C++中使用接口
    C++模版使用
    *获取mac地址的方法
    *数字——字符之间的转换(转)
    eclipse雕虫小技一:eclipse打开文件目录
    Hibernate升级后注解方式的对象关系映射
  • 原文地址:https://www.cnblogs.com/zhengwenwei/p/1965204.html
Copyright © 2011-2022 走看看