在Android应用程序时,当我开始活动了显示黑色屏幕或应用程序挂在几秒钟。我想直到黑屏我想显示进度条。我尝试了很多次,但无法做到这一点。应用程序挂起不调用Web服务或任何网络呼叫
String xml = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>"
+ "<category><Id>" + catId + "</Id></category>";
StringBuilder resXML = new Connection().getResponseString("http://192.168.1.14/virtualMirror/productlisting.php", xml); // TODO URL change
if(!resXML.equals("")) {
XMLParser parser = new XMLParser();
Document doc = parser.getDomElement(resXML.toString()); // getting DOM element
NodeList nodeList = doc.getElementsByTagName("Product");
Intent intent = new Intent(this, ProductListing.class);
Bundle bundle = new Bundle();
bundle.putLong("CategoryId", catId);
bundle.putString("CategoryName", catName);
intent.putExtras(bundle);
startActivity(intent);
}
使用Aysnctask ..在Google中查找示例。有很多可用 –
看看我的答案。它在我的情况下工作。 –