我是android开发的新手。我正在尝试加载一些我想异步执行的网络数据,以便在网络操作完成之前显示启动画面。现在,当我运行 belo 时,启动画面不会显示,而是显示一个带有标题栏的空白屏幕上吊状态。
我也在清单文件中将此活动标记为 LAUNCHER。你能告诉我什么是正确的方法吗?
这是我的启动画面代码。
public class SplashScreen extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
try{
AsyncTask<Void, Void, HukumNamaDetails> async=new URLReader(splashScreen).execute();
hdetails=async.get();
splashScreen.saveImage(currdate);
}
catch(InterruptedException e) {} catch (ExecutionException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
finally {
System.out.println("In finally");
finish();
//start a new activity
Intent i = new Intent();
i.putExtra("hdetails", new HukumNamaDetails(hdetails.getHukumnama_punjabi()
,hdetails.getPunjabi_vyakhya(),hdetails.getEnglish_translation()));
i.setClass(splashScreen, Daily_HukumNama.class);
startActivity(i);
}
}
//Function that will handle the touch
@Override
public boolean onTouchEvent(MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
synchronized(splashTread){
splashTread.notifyAll();
}
}
return true;
}
}
谢谢阿曼迪普