我有一个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
}
}
}
}
我提前感谢任何帮助。谢谢
答案 0 :(得分:12)
您是否尝试过使用Bundle.putStringArrayList或Intent.putStringArrayListExtra?
如果您的意思是不知道如何从服务开始活动,请尝试this question。