android - 将 List<String> 放入 Bundle

标签 android arraylist bundle intentservice

我有一个 IntentService,它连接到一个网站并通过 JSoup 创建一个包含已解析 HTML 的列表。我现在需要将该列表返回到 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
             }

        }
    }   
}

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

最佳答案

您尝试过使用 Bundle.putStringArrayListIntent.putStringArrayListExtra 吗?

如果您的意思是您不知道如何从服务启动 Activity ,请尝试 this question

关于android - 将 List<String> 放入 Bundle,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14969663/

相关文章:

java - 使用 GSON 解析混合类型的对象

java - 如何删除工具栏底部边距?

android - 将游标数据复制到 arraylist

java - 当 ArrayList 频繁更改时,访问特定的 ArrayList 元素

xcode - 如何使用 cmake 将资源包添加到 xcode 项目中?

java - 如何在 OSGi (Apache Felix) 中注册服务?

android - 以编程方式更改文本更正功能

java - 在java中用null填充ArrayList的最快方法是什么?

ios - iOS 9 上的 bundle 设置页面无法按预期工作

android - android 设备上是否需要预装 SL4A 才能运行 python 开发的应用程序?