2017-07-19 39 views
0

我尝试打开本地的PDF,但由于此异常也不会打开:android.os.FileUriExposedException: file:///storage/emulated/0/appid/1438-938X_2015_07/0.pdf exposed beyond app through Intent.getData()Titanium appcelerator:FileUriExposedException - 如何使用Content Provider?

我想我需要使用一个内容提供商,但我怎么能得到的Appcelerator的content://路径?

+0

您可以分享您使用的Titanium SDK版本和Android API级别吗? – nebu

+0

我正在使用Ti SDk 6.0.4.GA和Android目标SDK 25.但我今天修好了! –

回答

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

我希望这有助于任何人有类似的问题!

+1

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

+0

仍然适用于我 –

0

Ti SDK 6.3.0修复了这个问题。

相关问题