作家
登录

使用Intent打开第三方应用及验证可用性

作者: 来源: 2017-09-07 15:38:17 阅读 我要评论

 used, for example, to implement an "open" button when browsing   
  •      * through packages.  The current implementation looks first for a main   
  •      * activity in the category {@link Intent#CATEGORY_INFO}, and next for a   
  •      * main activity in the category {@link Intent#CATEGORY_LAUNCHER}. Returns  
  •      * <code>null</code> if neither are found.  
  •      *   
  •      * @param packageName The name of the package to inspect. 
  •      *   
  •      * @return A fully-qualified {@link Intent} that can be used to launch the   
  •      * main activity in the package. Returns <code>null</code> if the package   
  •      * does not contain such an activity, or if <em>packageName</em> is not   
  •      * recognized.   
  •      */  
  •  
  •     public abstract Intent getLaunchIntentForPackage(String packageName);   
  • 所以应用此方法剖断 Intent 是否为空即可。

    1. String package_name = "xx.xx.xx";   
    2. PackageManager packageManager = getPackageManager();   
    3. Intent it = packageManager.getLaunchIntentForPackage(package_name);   
    4. if (it != null){   
    5.     startActivity(it);   
    6. }else{   
    7.     //没有默认的人口 Activity   
    8. }  

    2. 应用 Intent.setComponent()

    1. String package_name = "xx.xx.xx";   
    2. String activity_path = "xx.xx.xx.ab.xxActivity"

        推荐阅读

        程序员经常说的「设计模式」到底是什么?

      【编辑推荐】 大年夜法度榜样员到CTO,可能就差这一次改变 知加一周精选:法度榜样员上周薪资播报出炉,快来看看你的热度 终于找到法度榜样员无休止加班的原因了! 揭秘项目经>>>详细阅读


      本文标题:使用Intent打开第三方应用及验证可用性

      地址:http://www.17bianji.com/lsqh/37221.html

    关键词: 探索发现

    乐购科技部分新闻及文章转载自互联网,供读者交流和学习,若有涉及作者版权等问题请及时与我们联系,以便更正、删除或按规定办理。感谢所有提供资讯的网站,欢迎各类媒体与乐购科技进行文章共享合作。

    网友点评
    自媒体专栏

    评论

    热度

    精彩导读
    栏目ID=71的表不存在(操作类型=0)