我必须在应用程序中显示来自远程URL链接的不同类型的文档。我使用谷歌文件在网页视图这样在android web视图中使用google doc显示.DOCX文件给出错误
private WebView mWvHome = (WebView) view.findViewById(R.id.wv_home);
mWvHome.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int progress) {
}
});
mWvHome.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return false;
}
@Override
public void onReceivedSslError(WebView view, final SslErrorHandler handler, SslError error) {
}
});
mWvHome.getSettings().setJavaScriptEnabled(true); // enable javascript
//Pasting a Fixed URL link to the file I am getting this Error.
mWvHome.loadUrl("http://docs.google.com/gview?embedded=true&url=http://followitdc.cloudapp.net/FollowitMediaAPIv4/images/bb629006-d930-4fbe-b9ec-91895dc5133c.docx");
这是我的布局文件
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white">
<ProgressBar
android:id="@+id/progress"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="@dimen/margin_normal"
android:layout_alignParentTop="true"
android:max="100"
android:progress="0"
android:progressDrawable="@drawable/custom_progressbar"
android:visibility="visible" />
<WebView
android:id="@+id/wv_home"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/progress" />
<RelativeLayout
android:id="@+id/rl_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/progress"
android:background="@color/white">
<ProgressBar
style="?android:attr/progressBarStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" />
</RelativeLayout>
</RelativeLayout>
装载正从谷歌文档这个响应后。
小于2MB .docx格式的文件加载某些文件小于2MB也没有加载。这是什么问题?它是文件大小问题还是文件错误?由于文件在Google文档联机编辑器中以及在Microsoft Word上正常工作。任何帮助将不胜感激。
http://docs.google.com/gview?embedded=true&url这不适用于某些android设备。 – MathaN
我应该怎么做才能修复它@MathaN –
如果您有后端团队告诉他们给出链接来阅读文档文件。会好起来的。我为我的申请做了同样的事情。 – MathaN