How to run progressDialog inside WebView ?

by teeming » Sat, 24 Apr 2010 01:48:37 GMT


Sponsored Links
 Hi,

I am new to android development. I wanted to create an app that
displaying a progressDialog when loading the webpage using
webview.loadurl. However i couldn't make my code run. The app is
loaded with error in the emulator. Below is my code. Hope anybody can
help me trace the problem. Thanks.

package hello.WebView;

import android.app.Activity;
import android.app.ProgressDialog;
import android.view.KeyEvent;
import android.webkit.*;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;

public class HelloWebView extends Activity implements Runnable {

        WebView webview;
        private ProgressDialog pd;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
    }

        @Override
        public boolean onKeyDown(int keyCode, KeyEvent event) {

                pd = ProgressDialog.show(this, "", "Loading...", true,
                                false);

                Thread thread = new Thread(this);
                thread.start();

                return super.onKeyDown(keyCode, event);
        }

        public void run() {

                webview.loadUrl(" http://m.adoimagazine.com ");
                setContentView(webview);
                handler.sendEmptyMessage(0);


        }
        private Handler handler = new Handler() {
                @Override
                public void handleMessage(Message msg) {
                        pd.dismiss();

                }
        };

    }

--



How to run progressDialog inside WebView ?

by Kumar Bibek » Mon, 26 Apr 2010 13:39:48 GMT


 You can put a progressbar inside a WebView and set or unset it's
visibility. That should solve your problem.

Thanks and Regards,
Kumar Bibek



>


Sponsored Links


Other Threads

1. Is there a way to determine which carrier the phone is using?

Is there a way to determine which carrier the phone is using.  T-
Mobile, Spring, AT&T, etc?
--~--~---------~--~----~------------~-------~--~----~

2. Deadlock in GLSurfaceView

We are developing an application that uses a GLSurfaceView to display
3D objects. We regularly get the "Application Not Responding" dialog.
Inspection of the dumped threads reveals something that looks
suspiciously like a deadlock. I have added the three thread dumps
involved below.

The first thread is the main application event thread, and it is
waiting on a join with a GLThread.

The second thread is a brand new GLThread that is waiting for a
semaphore lock presumably so it knows it has exclusive access to the
graphics hardware.

The third thread is probably a previous GLThread (the one the main
thread is waiting for to finish), that is waiting to be notified. The
strange thing is that the main application thread has just done a
"mDone=true; notify();" prior to calling "wait()", so the third thread
should have been awaken?

- Has anyone else run into this issue?
- Does anyone know of a workaround?

Any help would be appreciated!

DALVIK THREADS:
"main" prio=5 tid=3 WAIT
  | group="main" sCount=1 dsCount=0 s=0 obj=0x40018e70
  | sysTid=713 nice=0 sched=0/0 handle=-1093387108
  at java.lang.Object.wait(Native Method)
  - waiting on <0x2976e0> (a java.lang.VMThread)
  at java.lang.Thread.join(Thread.java:1020)
  at java.lang.Thread.join(Thread.java:974)
  at android.opengl.GLSurfaceView$GLThread.requestExitAndWait
(GLSurfaceView.java:1056)
  at android.opengl.GLSurfaceView.onDetachedFromWindow
(GLSurfaceView.java:447)
  at android.view.View.dispatchDetachedFromWindow(View.java:5230)

"GLThread" prio=5 tid=23 WAIT
  | group="main" sCount=1 dsCount=0 s=0 obj=0x43516a80
  | sysTid=1188 nice=0 sched=0/0 handle=3235208
  at java.lang.Object.wait(Native Method)
  - waiting on <0x2976e0> (a java.lang.VMThread)
  at java.lang.Thread.parkFor(Thread.java:1497)
  at java.lang.LangAccessImpl.parkFor(LangAccessImpl.java:48)
  at sun.misc.Unsafe.park(Unsafe.java:319)
  at java.util.concurrent.locks.LockSupport.park(LockSupport.java:117)
  at
java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt
(AbstractQueuedSynchronizer.java:680)
  at
java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireSharedInterruptibly
(AbstractQueuedSynchronizer.java:836)
  at
java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly
(AbstractQueuedSynchronizer.java:1143)
  at java.util.concurrent.Semaphore.acquire(Semaphore.java:267)
  at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:883)

"GLThread" prio=5 tid=19 WAIT
  | group="main" sCount=1 dsCount=0 s=0 obj=0x435e4098
  | sysTid=1184 nice=0 sched=0/0 handle=4061600
  at java.lang.Object.wait(Native Method)
  - waiting on <0x1c74b8> (a android.opengl.GLSurfaceView$GLThread)
  at java.lang.Object.wait(Object.java:288)
  at android.opengl.GLSurfaceView$GLThread.guardedRun
(GLSurfaceView.java:925)
  at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:887)

--~--~---------~--~----~------------~-------~--~----~

3. Droid Wall - Android Firewall

4. video screen disappeared after launch new task

5. H264 codec

6. ANN: Facebook Connect library for Android

7. Did Android support make a dial in native code