简体   繁体   English

当我滚动浏览我的 webview 应用程序时,我的应用程序冻结

[英]My app is freezing when I scroll through my webview application

The application consists of a simple splash screen and webview.该应用程序由一个简单的闪屏和 webview 组成。 But when it comes to the webview side, there is a problem of freezing in the application.但是说到webview端,应用中就出现了卡顿的问题。 It doesn't work exactly when I scroll.当我滚动时它不完全工作。 There is no freeze in the normal browser.普通浏览器没有冻结。 What is the problem问题是什么

Splash Screen启动画面


    @Override
    protected void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash_screen);

        Handler handler = new Handler();
        handler.postDelayed(new Runnable() {
            @Override
            public void run() {
                startActivity(new Intent(SplashScreen.this,MainActivity.class));
                finish();
            }

        }, 1200);



    }
}

This is Main activity Main Activity这是主要活动主要活动


   private final static int FCR = 1;
   WebView webView;
   private String mCM;
   private ValueCallback<Uri> mUploadMessage;
   public ValueCallback<Uri[]> uploadMessage;
   public static final int REQUEST_SELECT_FILE = 100;
   private final static int FILECHOOSER_RESULTCODE = 1;

   @SuppressLint("WrongViewCast")
   @Override
   protected void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
       setContentView(R.layout.activity_main);

       webView = findViewById(R.id.webView);
       webView.loadUrl("https://dokuzlama.com");
       WebSettings webSettings = webView.getSettings();
       webSettings.setJavaScriptEnabled(true);
       webSettings.setSupportZoom(false);
       webSettings.setAllowFileAccess(true);
       webSettings.setAllowFileAccess(true);
       webSettings.setAllowContentAccess(true);

       webView.setWebViewClient(new Callback());
       webView.setWebChromeClient(new WebChromeClient()
       {
           // For 3.0+ Devices (Start)
           // onActivityResult attached before constructor
           protected void openFileChooser(ValueCallback uploadMsg, String acceptType)
           {
               mUploadMessage = uploadMsg;
               Intent i = new Intent(Intent.ACTION_GET_CONTENT);
               i.addCategory(Intent.CATEGORY_OPENABLE);
               i.setType("image/*");
               startActivityForResult(Intent.createChooser(i, "File Browser"), FILECHOOSER_RESULTCODE);
           }


           // For Lollipop 5.0+ Devices
           public boolean onShowFileChooser(WebView mWebView, ValueCallback<Uri[]> filePathCallback, WebChromeClient.FileChooserParams fileChooserParams)
           {
               if (uploadMessage != null) {
                   uploadMessage.onReceiveValue(null);
                   uploadMessage = null;
               }

               uploadMessage = filePathCallback;

               Intent intent = fileChooserParams.createIntent();
               try
               {
                   startActivityForResult(intent, REQUEST_SELECT_FILE);
               } catch (ActivityNotFoundException e)
               {
                   uploadMessage = null;
                   Toast.makeText(MainActivity.this.getApplicationContext(), "Cannot Open File Chooser", Toast.LENGTH_LONG).show();
                   //eski---- >   Toast.makeText(getActivity().getApplicationContext(), "Cannot Open File Chooser", Toast.LENGTH_LONG).show();
                   return false;
               }
               return true;
           }

           //For Android 4.1 only
           protected void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType, String capture)
           {
               mUploadMessage = uploadMsg;
               Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
               intent.addCategory(Intent.CATEGORY_OPENABLE);
               intent.setType("image/*");
               startActivityForResult(Intent.createChooser(intent, "File Browser"), FILECHOOSER_RESULTCODE);
           }

           protected void openFileChooser(ValueCallback<Uri> uploadMsg)
           {
               mUploadMessage = uploadMsg;
               Intent i = new Intent(Intent.ACTION_GET_CONTENT);
               i.addCategory(Intent.CATEGORY_OPENABLE);
               i.setType("image/*");
               startActivityForResult(Intent.createChooser(i, "File Chooser"), FILECHOOSER_RESULTCODE);
           }
       });
   }

   public class Callback extends WebViewClient {
       public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
           Toast.makeText(getApplicationContext(), "Uygulama yüklenemedi", Toast.LENGTH_SHORT).show();
       }
   }

   @Override
   public void onActivityResult(int requestCode, int resultCode, Intent intent) {
       super.onActivityResult(requestCode, resultCode, intent);
       if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
           if (requestCode == REQUEST_SELECT_FILE) {
               if (uploadMessage == null)
                   return;
               uploadMessage.onReceiveValue(WebChromeClient.FileChooserParams.parseResult(resultCode, intent));
               uploadMessage = null;
           }
       } else if (requestCode == FILECHOOSER_RESULTCODE) {
           if (null == mUploadMessage)
               return;
           // Use MainActivity.RESULT_OK if you're implementing WebView inside Fragment
           // Use RESULT_OK only if you're implementing WebView inside an Activity
           Uri result = intent == null || resultCode != MainActivity.RESULT_OK ? null : intent.getData();
           mUploadMessage.onReceiveValue(result);
           mUploadMessage = null;
       } else
           Toast.makeText(MainActivity.this.getApplicationContext(), "Failed to Upload Image", Toast.LENGTH_LONG).show();
       //eski____ Toast.makeText(getActivity().getApplicationContext(), "Failed to Upload Image", Toast.LENGTH_LONG).show();
   }

   @Override
   public void onBackPressed() {
       if (webView.canGoBack()){
           webView.goBack();
       } else {
           super.onBackPressed();
       }
   }
}

Logcat view日志猫视图

05-18 19:38:45.529 4306-4306/? E/libprocessgroup: failed to make and chown /acct/uid_10059: Read-only file system
05-18 19:38:45.555 4306-4314/? E/art: Failed sending reply to debugger: Broken pipe
05-18 19:38:47.146 4306-4348/com.dokuzlama.dokuzlama E/libEGL: validate_display:255 error 3008 (EGL_BAD_DISPLAY)
05-18 19:38:47.171 4306-4348/com.dokuzlama.dokuzlama E/chromium: [ERROR:gl_surface_egl.cc(411)] eglChooseConfig failed with error EGL_SUCCESS
05-18 19:38:47.221 4306-4348/com.dokuzlama.dokuzlama E/chromium: [ERROR:gl_surface_egl.cc(411)] eglChooseConfig failed with error EGL_SUCCESS
05-18 19:38:49.485 4306-4353/com.dokuzlama.dokuzlama E/chromium: [ERROR:tile_manager.cc(779)] WARNING: tile memory limits exceeded, some content may not draw
05-18 19:38:49.486 4306-4353/com.dokuzlama.dokuzlama E/chromium: [ERROR:tile_manager.cc(779)] WARNING: tile memory limits exceeded, some content may not draw
05-18 19:38:49.541 4306-4353/com.dokuzlama.dokuzlama E/chromium: [ERROR:tile_manager.cc(779)] WARNING: tile memory limits exceeded, some content may not draw
05-18 19:38:49.542 4306-4353/com.dokuzlama.dokuzlama E/chromium: [ERROR:tile_manager.cc(779)] WARNING: tile memory limits exceeded, some content may not draw
05-18 19:38:49.923 4306-4353/com.dokuzlama.dokuzlama E/chromium: [ERROR:tile_manager.cc(779)] WARNING: tile memory limits exceeded, some content may not draw
05-18 19:38:49.924 4306-4353/com.dokuzlama.dokuzlama E/chromium: [ERROR:tile_manager.cc(779)] WARNING: tile memory limits exceeded, some content may not draw
05-18 19:38:50.003 4306-4353/com.dokuzlama.dokuzlama E/chromium: [ERROR:tile_manager.cc(779)] WARNING: tile memory limits exceeded, some content may not draw
05-18 19:38:50.004 4306-4353/com.dokuzlama.dokuzlama E/chromium: [ERROR:tile_manager.cc(779)] WARNING: tile memory limits exceeded, some content may not draw

I researched and analyzed a lot but I couldn't find.我研究和分析了很多,但我找不到。 The app is working.该应用程序正在运行。 But I think It's not stabile.但我认为它并不稳定。

I solved problem.我解决了问题。 android: hardwareAccelerated = I added the "true" manifest file and the problem with it has been removed. android:hardwareAccelerated = 我添加了“真正的”清单文件,问题已被消除。

<activity
            android:name=".MainActivity"
            android:hardwareAccelerated="true">
        </activity>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM