3 回答
TA贡献1869条经验 获得超4个赞
edwardxu的解决方案非常适合我。
只是澄清一下:
PackageManager packageManager = getActivity().getPackageManager();
if (intent.resolveActivity(packageManager) != null) {
startActivity(intent);
} else {
Log.d(TAG, "No Intent available to handle action");
}
TA贡献1993条经验 获得超5个赞
PackageManager manager = context.getPackageManager();
List<ResolveInfo> infos = manager.queryIntentActivities(intent, 0);
if (infos.size() > 0) {
//Then there is an Application(s) can handle your intent
} else {
//No Application can handle your intent
}
您是否尝试过此意图?
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.fromFile(yourFileHere));
TA贡献1796条经验 获得超4个赞
if (intent.resolveActivity(getPackageManager()) == null) {
// No Activity found that can handle this intent.
}
else{
// There is an activity which can handle this intent.
}
- 3 回答
- 0 关注
- 504 浏览
添加回答
举报