小编Gop*_*thi的帖子

Android Webview 有时无法呈现 pdf,而是显示空白/白页

  • 使用 google docs 在 webview 中打开 pdf
  • 一次又一次地打开相同的 pdf 或不同的 pdf。
  • 有时它会在android中显示空白/白色页面,直到我们再次刷新网页1或2次。

我已经在pdf上制作了样本。该项目的链接如下所示:

https://github.com/gopalawasthi123/PdfWebView

希望这能更好地帮助你。

public void SetWebView(WebView webview,string externalUrl){
            webview.Tag = "webview";
            webview.Settings.JavaScriptEnabled = true;
            webview.Settings.SupportZoom ();
            webview.Settings.SetAppCacheEnabled(true);
            webview.Settings.DomStorageEnabled = true;
            webview.ZoomOut ();
            webview.ZoomIn ();
            webview.Settings.BuiltInZoomControls = true;
            webview.Settings.LoadWithOverviewMode = true;
            webview.Settings.UseWideViewPort = true;
            //webview.Settings.SetSupportZoom (true);
            webview.Settings.SetPluginState (WebSettings.PluginState.On);
            webview.Settings.GetPluginState ();
            if (externalUrl.StartsWith("http://") || externalUrl.StartsWith("https://"))
                webview.LoadUrl (externalUrl);
            webview.SetWebViewClient (new MonkeyWebViewClient (imgViewBack, imgViewForward, imgRefresh));
            webview.SetWebChromeClient (new WebChromeClient ());
        }
Run Code Online (Sandbox Code Playgroud)

c# java android android-webview xamarin.android

14
推荐指数
2
解决办法
3693
查看次数

即使目标 Sdk 设置为 28,在 Android 10 上存储位图时应用程序也会崩溃?

我通过存储在 MediaStore 中将位图附加到 Imageview。它在 android 10 以下的所有设备上都可以正常工作,但是当像素发生崩溃时。我的 android id 定位到 sdk 28

try {
                Bitmap thePic = MediaStore.Images.Media.GetBitmap(ContentResolver, croppedPicUri);
                if(thePic != null){
                    imgProfileIcon.SetImageBitmap(thePic);

                //mediaStorageDir = Environment.GetExternalStoragePublicDirectory(Environment.DirectoryDcim);
                mediaStorageDir = GetExternalFilesDir(Environment.DirectoryPictures);
                if (!mediaStorageDir.Exists())
                {
                    mediaStorageDir.Mkdirs();
                }


                // Create a media file name
                String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").Format(new Java.Util.Date());
                sendFile = new File(mediaStorageDir.Path + File.Separator + "IMG_" + timeStamp + ".png");

                String path_ = MediaStore.Images.Media.InsertImage(this.ContentResolver, thePic, "Title", null);
                if (path_ != null){
                    Uri tempUri = Uri.Parse(path_);
                    path = GetPathToImage(tempUri);
                }
                }
            } catch …
Run Code Online (Sandbox Code Playgroud)

android mediastore xamarin.android xamarin

5
推荐指数
2
解决办法
2960
查看次数