【问题标题】:Titanium appcelerator: FileUriExposedException - How to use Content Provider?Titanium appcelerator:FileUriExposedException - 如何使用 Content Provider?
【发布时间】:2017-07-19 12:34:51
【问题描述】:

我尝试打开本地 pdf,但由于以下异常而无法打开:android.os.FileUriExposedException: file:///storage/emulated/0/appid/1438-938X_2015_07/0.pdf exposed beyond app through Intent.getData()

我想我需要使用内容提供程序,但是如何在 appcelerator 中获取 content:// 路径?

【问题讨论】:

  • 您能分享一下您使用的 Titanium SDK 版本和 Android API 级别吗?
  • 我使用的是 Ti SDk 6.0.4.GA 和 Android 目标 SDK 25。但我今天修好了!

标签: javascript appcelerator titanium-mobile


【解决方案1】:

今天我能够解决我的问题。我不必使用内容提供商。 我正在使用这段代码来创建一个 Intent:

            Ti.Android.currentActivity.startActivity(Ti.Android.createIntent({
            action: Ti.Android.ACTION_VIEW,
            type: 'application/pdf',
            data: pdfPath
        }));

不,我正在使用此代码:

var intent = Ti.Android.createIntent({
            action : Ti.Android.ACTION_VIEW,
            type : "application/pdf",
            data: pdfPath
        }); 


        var open = Ti.Android.createIntentChooser(intent, L('open_intent'));
        Ti.Android.currentActivity.startActivity(open);

希望对遇到类似问题的人有所帮助!

【讨论】:

  • 此解决方案不适用于在 Android 7+ 上运行的 Ti SDK 6.2.2 和 Android 目标 SDK 25。
【解决方案2】:

Ti SDK 6.3.0 中有一个修复程序解决了这个问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-05-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多