1
final Uri uri = Uri.fromFile(file);

final Intent intent = new Intent(Intent.ACTION_VIEW);

intent.setDataAndType(uri, "application/vnd.ms-powerpoint");

PackageManager pm = getPackageManager();

List<ResolveInfo> list = pm.queryIntentActivities(intent, 0);

if(list.size() > 0)

startActivity(context, intent);`

上記を見ると、コードは Android タブレットに MS ppt を表示するためのものです。

今私のコード手順は次のとおりです。

1.URL から ppt をダウンロードし、sdcard に保存します。

2.次に、これに適しているかどうかわからないビューにpptを表示したいと思います。

そのため、pptだけでなくdoc / ppt / pdf / xlsファイルもビューに表示したいのですが、実際にはpptを表示できません.....

では、どうやってそれを行うのですか?????

4

2 に答える 2

0

これにはWebviewを使用してください。それは私のために働いた。

WebView mWebView = (WebView) findViewById( R.id.WebView01);
String pdfurl = ""; // Url of pdf or doc file.

String weblink="http://docs.google.com/gview?embedded=true&url="+pdfurl;    
mWebView.loadUrl(weblink);
于 2013-01-02T06:16:24.333 に答える
0
    Hi friend I fased Same problem 
    that time instead of specifing we can pick suitable application from list of Application , 
    but below code is for example purpose only , not for 100% gurantee 
    depends on Requirement you have to change .



In ICS You have default polaris application you can use 


         else if (TEXT == type) {
                    File targetFile = new File(path);
                    Uri targetUri = Uri.fromFile(targetFile);
                    Intent intent = new Intent(Intent.ACTION_VIEW);
                    intent.setDataAndType(targetUri, "text/plain");
                    startActivityForResult(intent, TEXT);
                } else if (type == DOC) {
                    File targetFile = new File(path);
                    Uri targetUri = Uri.fromFile(targetFile);
                    Intent intent = new Intent(Intent.ACTION_VIEW);
                    intent.setDataAndType(targetUri, "application/*");
                    startActivityForResult(intent, DOC);
                } else if (type == EXCEL) {
                    File targetFile = new File(path);
                    Uri targetUri = Uri.fromFile(targetFile);
                    Intent intent = new Intent(Intent.ACTION_VIEW);
                    intent.setDataAndType(targetUri, "application/*");
                    startActivityForResult(intent, EXCEL);
                } else {
                    File targetFile = new File(path);
                    Uri targetUri = Uri.fromFile(targetFile);
                    Intent intent = new Intent(Intent.ACTION_VIEW);
                    intent.setDataAndType(targetUri, "application/*");
                    startActivityForResult(intent, 0);
                }
于 2013-01-02T06:24:46.920 に答える