android queryIntentActivities如何寻找出某个intent是否可用
来源:互联网 发布:android网络编程 编辑:程序博客网 时间:2024/06/07 04:03
Finding out if an intent is available
Sometimes you want to find if an application has registered for a certain intent. For example you want to check if a certain receiver is available and if you enable some functionality in your app.
某些时候你想要知道某个AP是否有注册了一个明确的intent,比如说你想要检查某个receiver是否存在,然后根据是否存在来这个receiver来在你的AP里面enable某些功能
This can be done via checking the PackageManager. The following code checks if an intent exists. You can check via this method for intent and change your application behavior accordingly for example disable or hide menu items.
我们可以通过PackageManager来check它,下面的代码检测了一个intent是否存在.
- public boolean isIntentAvailable(Context context, String action) {
- final PackageManager packageManager = context.getPackageManager();
- final Intent intent = new Intent(action);
- List<ResolveInfo> resolveInfo =
- packageManager.queryIntentActivities(intent,
- PackageManager.MATCH_DEFAULT_ONLY);
- if (resolveInfo.size() > 0) {
- return true;
- }
- return false;
- }
1 0
- 【Android】如何寻找出某个Intent是否可用(queryIntentActivities)
- android queryIntentActivities如何寻找出某个intent是否可用
- Android 判断某个Intent是否可用
- 【Android】判断某个App是否安装并启动(queryIntentActivities),
- 判断Intent是否安全的方法queryIntentActivities的使用
- 如何判断是否可以使用某个Intent
- 检测android某个intent是否有效
- 检测Intent是否可用
- Android中如何判断Intent是否存在
- Android中如何判断Intent是否存在?
- 如何判断android 网络连接是否可用
- 判断一个intent是否可用的接口
- 测试某个tty设备是否可用
- Android网络是否可用
- Android如何检测SD卡某个目录是否存在
- Android开发中如何判断是否安装了某个程序
- Android如何判断手机里是否安装了某个应用
- Robot Framework如何判断Android屏幕是否含有某个控件
- for each循环
- eclipse插件教程之复制内容到剪贴板
- Android : assets与res/raw资源目录的区别
- android 协作项目的签名文件的问题,以后补充一下
- 抽象类和接口的区别以及使用场景(记)
- android queryIntentActivities如何寻找出某个intent是否可用
- IOS后台 返回 /Date(1445340103367)/ 时间,转换成 2015-10-20 19:21 这种格式
- 关于c++多态
- ORA-19502: write error on file "", block number (block size
- C++中数组和容器的区别与联系
- spring boot 学习小结1 spring mvc环境搭建
- Ubuntu Server 14.04开发环境配置
- ip修改切换(bat批处理文件)
- 【codeforces 576D】LCS Again