On Aug 4, 6:17 pm, "droidin.net" <[email protected]> wrote:
> want toloadURL directly into the WebView#loadURL, so how do I do it
> on a background thread?
You don't display the page from a background thread, you display
things in the UI thread. You load and/or process the data in a
background thread. This is a way of doing that, I'm sure there's other
ways to do it.
private void loadInBackground() {
final Runnable runInUIThread = new Runnable() {
public void run() {
// do stuff in UI thread after
}
};
new Thread() {
@Override
public void run() {
// do stuff in background first
// then call UI thread
mHandler.post(runInUIThread);
}
}.start();
}
>
> On Aug 4, 3:12 am, Christine <[email protected]> wrote:
>
> > I take it you don't already have a bg thread, or you wouldn't have the
> > problem?
>
> > The cute way of loading data in the background is to use aservice.
> > The simple way is to use a Handler, as Peter suggested. In the handler
> > task, you create a new thread that does the http stuff. If the user
> > needs to wait for the data to display anyway, I think you can prevent
> > the timeout from happening by using a progress bar.
>
> > On Aug 4, 1:07 am, "droidin.net" <[email protected]> wrote:
>
> > > In my app I have toloadexternal page into WebView-based activity.
> > > Some of my users with slower connections are reporting screen timeout
> > > while waiting for the page toload. What would be a good way of
> > > loading the page on backgorund thread and then refreshing the screen?
> > > Use HttpClient to fetch it and then use WebView#loadData? My fear is -
> > > the page I'm loading is pretty complicated there's some JS that
> > > happens onload- wouldn't I just mess it up? Is there an alternative
> > > way of doing what I need?
>
> > > Thanks,
>
> > > Bo
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---