Android-是否可以将phonegap应用程序与非phonegap应用程序集成

Android-是否可以将phonegap应用程序与非phonegap应用程序集成,android,cordova,documentviewer,Android,Cordova,Documentviewer,我的尝试: 我正在开发一个android应用程序。在我的应用程序中,我必须打开->向用户显示microsoft office文档(doc、docx、xls、xlsx、ppt、pptx)内容。为此,我尝试了多种方法(apachi poi、docx4j)。但我没能完成 因此,我决定在我的应用程序中使用第三方文档SDK显示文档 但这对我没有帮助。与此同时,我得到了一些建议。通过使用phonegap,Fileopener插件,我们可以打开->向用户显示文档 我需要什么: 我已经开发了一个非phon

我的尝试:

我正在开发一个android应用程序。在我的应用程序中,我必须打开->向用户显示microsoft office文档(doc、docx、xls、xlsx、ppt、pptx)内容。为此,我尝试了多种方法(apachi poi、docx4j)。但我没能完成

因此,我决定在我的应用程序中使用第三方文档SDK显示文档

但这对我没有帮助。与此同时,我得到了一些建议。通过使用phonegap,Fileopener插件,我们可以打开->向用户显示文档

我需要什么:

我已经开发了一个非phonegap应用程序。如果我使用phonegap创建文档查看器,是否可以将phonegap应用程序集成到我的非phonegap应用程序中


我不熟悉电话鸿沟。如果可能,请给出一些想法(或)步骤

在您的非phoneGap应用程序中,当用户想要打开文档时(如果您坚持使用phoneGap),只需打开一个
webView
,然后在其中打开您的phoneGap应用程序(网页)。

文件开启器插件只需启动一个intent,其他应用程序就会打开文件,而不是您的应用程序,因此您不需要phoneGap,只需查看插件代码,并在您的android项目中执行同样的操作

有几个插件。


只需更改
this.cordova.getActivity()
就可以在调用代码的类中获得活动。

感谢您的回复。你能告诉我,如何将phonegap与非phonegap应用程序集成吗?phonegap应用程序是一些html/css/javascript文件。将这些文件放在您的资产文件夹中,然后在打开
WebView
后,告诉它加载您的
index.html
(phonegap的主文件),现在您就完成了。我在示例phonegap应用程序中看到了一些文件夹,如CordovaLib/cordova/platform\u www/folders。我还需要添加这些文件夹吗?您只需要添加自己的html/css/javascript文件+电话间隙库,如cordova.js,等等,非常感谢Mohammad Rahchamani。这种方法对我没有帮助。我是说文件开启器和电话缺口。因为我想在我的应用程序中显示microsoft文档。此Fileopener将启动其他意图以显示microsoft文档。感谢您的帮助。否则,我将花费一些时间来实现这一点。因为我是新加入phonegap的:)我添加了一个例子,你对我的要求(问题中给出的)有什么想法吗?我想在我的应用程序中显示office文档(而不是打开其他意图)。如果要显示的文件位于internet上,则可以使用Web视图并使用google docs url()加载文件。如果他们在应用程序中,你应该继续尝试你在问题中提到的解决方案。否。我想在脱机模式下显示文档。即用户必须从SDCard中选择该单据。
private void openFile(String url) throws IOException {
    // Create URI
    Uri uri = Uri.parse(url);
    Intent intent = null;
    // Check what kind of file you are trying to open, by comparing the url with extensions.
    // When the if condition is matched, plugin sets the correct intent (mime) type,
    // so Android knew what application to use to open the file
    if (url.contains(".doc") || url.contains(".docx")) {
        // Word document
        intent = new Intent(Intent.ACTION_VIEW);
        intent.setDataAndType(uri, "application/msword");
    } else if(url.contains(".pdf")) {
        // PDF file
        intent = new Intent(Intent.ACTION_VIEW);
        intent.setDataAndType(uri, "application/pdf");
    } else if(url.contains(".ppt") || url.contains(".pptx")) {
        // Powerpoint file
        intent = new Intent(Intent.ACTION_VIEW);
        intent.setDataAndType(uri, "application/vnd.ms-powerpoint");
    } else if(url.contains(".xls") || url.contains(".xlsx")) {
        // Excel file
        intent = new Intent(Intent.ACTION_VIEW);
        intent.setDataAndType(uri, "application/vnd.ms-excel");
    } else if(url.contains(".rtf")) {
        // RTF file
        intent = new Intent(Intent.ACTION_VIEW);
        intent.setDataAndType(uri, "application/rtf");
    } else if(url.contains(".wav")) {
        // WAV audio file
        intent = new Intent(Intent.ACTION_VIEW);
        intent.setDataAndType(uri, "audio/x-wav");
    } else if(url.contains(".gif")) {
        // GIF file
        intent = new Intent(Intent.ACTION_VIEW);
        intent.setDataAndType(uri, "image/gif");
    } else if(url.contains(".jpg") || url.contains(".jpeg")) {
        // JPG file
        intent = new Intent(Intent.ACTION_VIEW);
        intent.setDataAndType(uri, "image/jpeg");
    } else if(url.contains(".png")) {
        // PNG file
        intent = new Intent(Intent.ACTION_VIEW);
        intent.setDataAndType(uri, "image/png");
    } else if(url.contains(".txt")) {
        // Text file
        intent = new Intent(Intent.ACTION_VIEW);
        intent.setDataAndType(uri, "text/plain");
    } else if(url.contains(".mpg") || url.contains(".mpeg") || url.contains(".mpe") || url.contains(".mp4") || url.contains(".avi")) {
        // Video files
        intent = new Intent(Intent.ACTION_VIEW);
        intent.setDataAndType(uri, "video/*");
    }
    //if you want you can also define the intent type for any other file
    //additionally use else clause below, to manage other unknown extensions
    //in this case, Android will show all applications installed on the device
    //so you can choose which application to use
    else { intent = new Intent(Intent.ACTION_VIEW);
        intent.setDataAndType(uri, "*/*");
    }
    this.cordova.getActivity().startActivity(intent);
}