Android外部PDF渲染立即关闭

我正在尝试从我的Android应用程序外部呈现PDF。 我的代码看起来像这样

val file = File(<path-to-pdf>)
val target = Intent(Intent.actION_VIEW)
target.setDataAndType(Uri.fromFile(file),"application/pdf")
target.flags = Intent.flaG_actIVITY_NO_HISTORY
val intent = Intent.createChooser(target,"Open With")
intent.flags = Intent.flaG_actIVITY_NEW_TASK
try {
      context.startactivity(intent)
} catch (e: activityNotFoundException) {
      Log.e(e.message)
}

每当在某些设备上运行时(到目前为止在Pixel 2上观察到),外部读取器都会启动并立即关闭。 解决方案建议here不起作用。

beibei0524 回答:Android外部PDF渲染立即关闭

这在使用默认Drive PDF Viewer的某些手机上不起作用。尝试通过应用选择器使用其他PDF查看器。

本文链接:https://www.f2er.com/3158941.html

大家都在问