在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中查找示例。有很多可用 –
看看我的答案。它在我的情況下工作。 –