判断安卓Intent或Action在系统中是否能被启动

来源:互联网 发布:怎样提高seo排名 编辑:程序博客网 时间:2024/04/29 07:45

判断安卓应用Intent或Action在系统中是否能被启动

    /*** @param   context The application's environment.* @param   intent The Intent to check for availability.* @return  True if an Intent with the specified action can be sent and*          responded to, false otherwise.*/public static boolean isIntentAvailable(Context context, Intent intent) {if((null == context) || (null == intent))return false;final PackageManager packageManager = context.getPackageManager();List<ResolveInfo> list = packageManager.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);    if(null == list)return false;return list.size() > 0;}
还可以将参数intent替换为action,在函数内new一个Intent再进行判断。


0 0
原创粉丝点击