【发布时间】:2018-12-21 15:25:47
【问题描述】:
我正在尝试使用 web 视图显示保存在 Firebase 存储中的 PDF 文件。但是我收到的视图是空白的,只有顶部是灰色的。
public class PerformanceFragment extends Fragment {
private WebView webView;
private String postUrl = "https://firebasestorage.googleapis.com/v0/b/sas-android-73b28.appspot.com/o/sequence.pdf?alt=media&token=9fc1de4e-1059-4b2b-865e-1c44453a7eb8";
public PerformanceFragment() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View root = inflater.inflate(R.layout.fragment_performance, container, false);
webView = root.findViewById(R.id.webView);
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl("http://drive.google.com/viewerng/viewer?embedded=true&url=" + postUrl);
webView.setHorizontalScrollBarEnabled(false);
webView.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int progress)
{
getActivity().setTitle("Loading...");
getActivity().setProgress(progress * 100);
if(progress == 100)
getActivity().setTitle(R.string.app_name);
}
});
return root;
}
}
fragment_performance.xml
<android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
tools:context=".PerformanceFragment">
<WebView
android:id="@+id/webView"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</android.support.v4.widget.NestedScrollView>
我已通过身份验证,但没有显示任何其他内容。屏幕截图如下:1
任何帮助将不胜感激。谢谢。
【问题讨论】:
-
检查这个答案,也许可以帮助stackoverflow.com/questions/47810673/…
标签: java android firebase-storage