在发送intent启动activity之前判断是否有activity接收

通过packagemanager()的queryIntentAActivities(intent,0)的返回list<ResolveInfo>长度来判断
具体代码如下:
PackageManager packageManager = getPackageManager();
List<ResolveInfo> activities = packageManager.queryIntentActivities(intent, 0);
boolean isIntentSafe = activities.size() > 0;

 

 
posted @ 2015-03-31 16:27  u3  阅读(189)  评论(0编辑  收藏  举报