我有我的 AndroidMainActivity
和它的setContentView
. 视图是黑色/蓝色渐变背景和ImageView
. 这是我的onCreate
:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
/**
* Activity elements
* */
ImageView rt_logo = (ImageView) findViewById(R.id.rt_logo);
/**
* Activity variables
* */
HttpGetRequest httpGetRequest = new HttpGetRequest(rt_logo);
try {
URI uri = new URI("http://www.myurl.com");
URI[] uris = {uri};
response = httpGetRequest.execute(uris).get();
[...]
}
为了检索页面的代码,我做了一个AsyncTask
. 对于调试,我使用睡眠 5 秒。
ImageView rt_logo;
public HttpGetRequest(ImageView _rt_logo) {
rt_logo = _rt_logo;
}
@Override
protected String doInBackground(URI... uris) {
HttpClient httpClient = new DefaultHttpClient();
HttpGet httpGet = new HttpGet(uris[0]);
[...]
SystemClock.sleep(5000);
getString = stringBuffer.toString();
return getString;
}
我的问题是,在黑色/蓝色渐变和徽标显示之前,我得到了 5 秒钟的白屏,我猜是在AsyncTask
.
为什么应用启动时收不到?
谢谢。