在发送intent启动activity之前判断是否有activity接收
通过packagemanager()的queryIntentAActivities(intent,0)的返回list<ResolveInfo>长度来判断
具体代码如下:
PackageManager packageManager = getPackageManager(); List<ResolveInfo> activities = packageManager.queryIntentActivities(intent, 0); boolean isIntentSafe = activities.size() > 0;
-----人若无名,则可专心练剑