我有启动活动,应该从 url 下载数据并解析它并将其传递给主要活动,在下载时我创建了带有徽标的布局和在 webview 中加载的旋转 gif,但是当我启动应用程序时什么也没发生,它不会启动主要活动这里是代码
public class Init extends Activity {
static final String DEFAULT_URL = "http://api.androidhive.info/music/music.xml";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.init);
WebView loader = (WebView) findViewById(R.id.loader);
loader.loadUrl("file:///android_asset/index.html");
new LoadingTask().execute(DEFAULT_URL);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
public class LoadingTask extends AsyncTask<String, String, String>{
XMLParser parser = new XMLParser();
@Override
protected String doInBackground(String... params) {
// TODO Auto-generated method stub
String URL = params[0];
String xml = parser.getXmlFromUrl(URL); // getting XML from URL
// getting DOM element
return xml;
}
protected void onPostExecute(String result){
Intent startApp = new Intent("com.example.androidhive.HOME");
startApp.putExtra("xmlstring", result);
//finish();
}
}
}