我的崩溃报告工具报告经常出错,主要是在Android 5.0.2上的小米设备上:
Fatal Exception: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.CREATE_DOCUMENT cat=[android.intent.category.OPENABLE] typ=application/pdf (has extras) }
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1765)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1602)
at android.app.Activity.startActivityFromFragment(Activity.java:4391)
at android.app.Fragment.startActivityForResult(Fragment.java:1100)
at android.app.Fragment.startActivityForResult(Fragment.java:1084)
有没有理由说这些设备不支持SAF?我怎么能以正确的方式解决这个问题呢?
答案 0 :(得分:2)
你能做的第一件事就是避免崩溃 -
if (intent.resolveActivity(getPackageManager()) != null) {
context.startActivity(intent);
} else {
Toast.makeToast(context, "No application found on device to open view", Toast.LENGTH_SHORT).show()
}
答案 1 :(得分:0)