3

我有一个IntentService连接到一个网站并通过 JSoup 创建一个带有解析 HTML 的列表。我现在需要将该列表传回 a 中Bundle,但我不知道该怎么做。这是我的代码IntentService

public class NewerService extends IntentService {

public NewerService() {
    super("NewerService");
    // TODO Auto-generated constructor stub
}

@Override
protected void onHandleIntent(Intent intent) {
    ResultReceiver rec = intent.getParcelableExtra("receiverTag");
    String playersName = intent.getStringExtra("Player");
    List<String> list = new ArrayList<String>();
    Document doc = null;
    try {
        doc = Jsoup.connect("http://espn.go.com/nhl/team/stats/_/name/phi/philadelphia-flyers").get();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    for (Element table : doc.select("table.tablehead")) {
        for (Element row : table.select("tr")) {
            Elements tds = row.select("td");
            if (tds.size() > 6) {
                String a = tds.get(0).text() + ":" + " Games Played: "+
                    tds.get(1).text()+"," + " GOALS: " + tds.get(2).text()+"," + 
                    " ASSISTS: " + tds.get(3).text() + " POINTS: " + 
                    tds.get(4).text() + " PLUS/MINUS: " + tds.get(5).text() + " 
                    PIM: " + tds.get(6).text();

                    list.add(a); // Add the string to the list
             }

        }
    }   
}

我提前感谢任何帮助。谢谢

4

1 回答 1

14

您是否尝试过使用Bundle.putStringArrayListIntent.putStringArrayListExtra

如果您的意思是您不知道如何从服务启动活动,请尝试这个问题

于 2013-02-19T23:40:19.447 回答