6

I am new in Android development. I have a problem with Android WebView only in Samsung Galaxy Tab 2. All other devices working fine.

My app contains only WebView with jquery. When the app starts, WebView gets loaded and then user interact only with WebView. In Samsung Galaxy Tab sometimes there was delay in loading contents of the WebView, otherwise it works perfectly. If there was a delay initially, then it needs an event to be happen (such as touch or orientation change) for loading, after that the app hangs completely.

Is there any settings to controll "Zoom" events?

I don't know , whether I miss something in the code. I am adding my code for reference. please help me to solve this problem. thanks in advance.

public class myApp extends Activity 
{
    WebView myWeb;

    @SuppressLint("SetJavaScriptEnabled")
    @Override
    public void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        myWeb=(WebView) findViewById(R.id.webView1);

        WebSettings webSettings=myWeb.getSettings();
        webSettings.setJavaScriptEnabled(true);
        myWeb.clearCache(true);

        myWeb.loadUrl("file:///android_asset/index.html");
    }
}
David Manpearl
  • 12,362
  • 8
  • 55
  • 72

1 Answers1

1

This portion of my answer is in regards to your WebView load and hang issues:

Move the loadUrl() in onCreate() out of the main UI thread with any number of methods, such as this...

Instead of this:

myWeb.loadUrl("file:///android_asset/index.html");

Use this:

Timer timer = new Timer();
timer.schedule(new TimerTask() {
    @Override
    public void run() {
        myWeb.loadUrl("file:///android_asset/index.html");
    }
}, 400);

Zoom:

Regarding the "Zoom" portion of the question, please see this post: enable/disable zoom in Android WebView

Community
  • 1
  • 1
David Manpearl
  • 12,362
  • 8
  • 55
  • 72