在发送intent启动activity之前判断是否有activity接收
通过packagemanager()的queryIntentAActivities(intent,0)的返回list长度来判断
具体代码如下:
PackageManager packageManager = getPackageManager(); Listactivities = packageManager.queryIntentActivities(intent, 0); boolean isIntentSafe = activities.size() > 0;