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條經驗 獲得超6個贊
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 關注
- 549 瀏覽
添加回答
舉報