The application consists of a simple splash screen and webview. But when it comes to the webview side, there is a problem of freezing in the application. 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.