Http 请求覆盖活动启动 - Android
嘿, 我遇到了一个奇怪的问题。我正在尝试启动一个活动,该活动直接进入进度对话框启动,然后发出 http 请求并将用户登录到各个站点。 onCreate() 中的代码如下所示:
setContentView(R.layout.upload);
ProgressDialog dialog = ProgressDialog.show(this, "Login", "Attempting to login now...", true);//the login progress dialog
executeUpload();
但是,当我运行此代码时,屏幕变为空白并延迟活动的启动,直到 exuteUpload() 完成。我有点难住了。有没有人遇到类似的问题或对可能导致此问题的原因有任何建议?
ExecuteUpload 非常简单:
state = new O2State();//for the O2 site
state.logon();
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 have any suggestions as to what could be causing this?
ExecuteUpload is simple enough:
state = new O2State();//for the O2 site
state.logon();
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
State.login 可能没有在另一个线程中运行。这将导致 UI 线程看似停止。
这可能是使用 AsyncTask 的候选者。
http://developer.android.com/reference/android/os/AsyncTask.html
也是一个AsyncTask教程
http://evancharlton.com/thoughts/rotating-async-tasks/
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/