Android不匹配的标签异常突然

时间:2014-03-18 07:43:03

标签: android

早期解析数据时,我从未得到Exception,但今天我突然得到了TAG mismatch Exception。我不知道自己哪里出错了。请帮帮我。

网址解析:http://development.21stcenturymart.com/TopCategory.php

错误追踪:

03-18 12:52:08.070: W/System.err(10156): org.apache.harmony.xml.ExpatParser$ParseException: At line 35, column 2: mismatched tag
03-18 12:52:08.070: W/System.err(10156):    at org.apache.harmony.xml.ExpatParser.parseFragment(ExpatParser.java:515)
03-18 12:52:08.070: W/System.err(10156):    at org.apache.harmony.xml.ExpatParser.parseDocument(ExpatParser.java:474)
03-18 12:52:08.070: W/System.err(10156):    at org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:321)
03-18 12:52:08.070: W/System.err(10156):    at org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:279)
03-18 12:52:08.070: W/System.err(10156):    at com.centuery.ctl21.Centuary_MainActivity$Toplist.doInBackground(Centuary_MainActivity.java:697)
03-18 12:52:08.070: W/System.err(10156):    at com.centuery.ctl21.Centuary_MainActivity$Toplist.doInBackground(Centuary_MainActivity.java:1)
03-18 12:52:08.070: W/System.err(10156):    at android.os.AsyncTask$2.call(AsyncTask.java:287)
03-18 12:52:08.070: W/System.err(10156):    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
03-18 12:52:08.070: W/System.err(10156):    at java.util.concurrent.FutureTask.run(FutureTask.java:137)
03-18 12:52:08.070: W/System.err(10156):    at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
03-18 12:52:08.070: W/System.err(10156):    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
03-18 12:52:08.070: W/System.err(10156):    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
03-18 12:52:08.070: W/System.err(10156):    at java.lang.Thread.run(Thread.java:856)

源代码

SAXParserFactory spf=SAXParserFactory.newInstance();      
        SAXParser sp= spf.newSAXParser();
        XMLReader xr=sp.getXMLReader();

        URL soUrl=new URL(CommonUtilities.url_TopCategoy);


        CategoryHandler dh = new CategoryHandler();
        xr.setContentHandler(dh);
        xr.parse(new InputSource (soUrl.openStream()));
        Log.v("urllllllllllllllll",""+soUrl);

1 个答案:

答案 0 :(得分:1)

最后在战斗之后这么久得到了解决方案。  我的问题是我的Wifi连接。它未连接到Authenticated Wifi Connection。因此要检查Wifi是启用还是禁用运行以下代码:  您可以注册BroadcastReceiver,以便在建立WiFi连接时(或连接已更改)收到通知。 注册BroadcastReceiver:

IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(WifiManager.SUPPLICANT_CONNECTION_CHANGE_ACTION);
registerReceiver(broadcastReceiver, intentFilter);

And then in your BroadcastReceiver do something like this:

@Override
public void onReceive(Context context, Intent intent) {
    final String action = intent.getAction();
    if (action.equals(WifiManager.SUPPLICANT_CONNECTION_CHANGE_ACTION)) {
        if (intent.getBooleanExtra(WifiManager.EXTRA_SUPPLICANT_CONNECTED, false)){
            //do stuff
        } else {
            // wifi connection was lost
        }
    }
}

有关详细信息,请参阅BroadcastReceiver和WifiManager的文档

当然,您应该在此之前检查设备是否已连接到WiFi。