开发者

Http requests overriding activity start up - Android

Hey, I've come across a strange problem. I'm trying to launch an activity that goes straight to a progress dialog launch and then makes a http request with logs the user into various sites. The code in onCreate() is something like this:

setContentView(R.layout.upload);
ProgressDialog dialog = ProgressDialog.show(this, "Login", "Attempting to login now...", true);//the login progress dialog
executeUpload();  

However, when I run this, the screen goes blank and delays launch of the activity until exuteUpload() completes. I'm a bit stumped. Has anyone some across a similar problem or h开发者_JS百科ave any suggestions as to what could be causing this?

ExecuteUpload is simple enough:

state = new O2State();//for the O2 site
state.logon();


State.login is probably not running in another Thread. This will cause the UI thread to seemingly stop.

This is likely candidate for using AsyncTask. http://developer.android.com/reference/android/os/AsyncTask.html

Also an AsyncTask tutorial http://evancharlton.com/thoughts/rotating-async-tasks/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜