我想直接在Android上的PDF查看器中打开PDF文件, 我不想使用谷歌文档,因为它不应该在浏览器上打开。
任何人都可以帮忙吗? 提前致谢
答案 0 :(得分:2)
您是否尝试过此代码:
try {
var f = Ti.Filesystem.getFile('your.pdf');
Ti.Android.currentActivity.startActivity(Ti.Android.createIntent({
action: Ti.Android.ACTION_VIEW,
type: 'application/pdf',
data: f.getNativePath()
}));
}
catch (err) {
var alertDialog = Titanium.UI.createAlertDialog({
title: 'No PDF Viewer',
message: 'We tried to open a PDF but failed. Do you want to search the marketplace for a PDF viewer?',
buttonNames: ['Yes','No'],
cancel: 1
});
alertDialog.show();
alertDialog.addEventListener('click', function(evt) {
if (evt.index == 0) {
Ti.Platform.openURL('http://search?q=pdf');
}
});
}
取自此处:http://developer.appcelerator.com/question/72361/open-pdf-file-on-android