gpt4 book ai didi

android - 将 List 放入 Bundle

转载 作者:太空狗 更新时间:2023-10-29 15:35:05 32 4
gpt4 key购买 nike

我有一个 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/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com