代码之家  ›  专栏  ›  技术社区  ›  David Illichmann

钛appcelerator:FileUriExposedException-如何使用内容提供商?

  •  0
  • David Illichmann  · 技术社区  · 7 年前

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

    我想我需要使用内容提供商,但我如何才能获得 content://

    2 回复  |  直到 7 年前
        1
  •  1
  •   David Illichmann    7 年前

    今天我解决了我的问题。我不需要使用内容提供商。 我用这段代码创建了一个意图:

                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);
    

        2
  •  0
  •   Raef Akehurst    7 年前

    Ti SDK 6.3.0中有一个补丁修复了这个问题。