Android 開発は初めてですが、xml パーサーを作成しようとしています。私はいくつかのチュートに従ってandroid.saxライブラリを使用してきましたが、これはうまく機能します。私が懐疑的になっていることの 1 つは、実際には別のスレッドでパーサーを起動していないことです。パーサーとメイン アクティビティとの間の通信にハンドラーを使用しているだけです。Thread で解析する必要がありますか?
これが私の主な活動コードです:
        tv = (TextView)findViewById(R.id.tv);
    try {
        URL url = new URL("https://www.googleapis.com/shopping/search/v1/public/products?key=AAAAABBBBBCCCCDDDEEEEFFF&country=FR&restrictBy=gtin=5030999075254&alt=atom");
        XMLHandler xHandler = new XMLHandler();
        Feed feed = xHandler.parse(url.openStream());
            if(feed.getTotalResults()==0 || feed.getItems() == null || feed.getItems().isEmpty()) {
                Log.w("XMLPARSENull", "No items
            }
            else {
                tv.setText(feed.getTotalResults()+" " + feed.getItemsPerPage() + " " + feed.getStartIndex() + " " + feed.getTitle());
                Iterator<Product> it = feed.getItems().iterator();
                while(it.hasNext()) {
                    Log.w("XMLPARSEFeed",it.next().getName());
                }
            }
    } catch(Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        Log.e("XMLPARSEException", "ERROR",e);
    }