这里是我的代码部分:jsoup并不在我的Android应用程序的工作,总是得到错误使用get()
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_lyrics_display);
setupActionBar();
TextView ArtistName = (TextView)findViewById(R.id.aname);
TextView SongName = (TextView)findViewById(R.id.sname);
// Get the message from the intent
Intent intent = getIntent();
String message = intent.getStringExtra(MainActivity.EXTRA_MESSAGE);
String message2 = intent.getStringExtra(MainActivity.EXTRA_MESSAGE2);
// Create the text view
ArtistName.setTextSize(12);
ArtistName.setText(message);
SongName.setTextSize(12);
SongName.setText(message2);
getLyrics(message , message2);
}
@SuppressLint("DefaultLocale")
public void getLyrics(String message , String message2) {
final TextView LyricsContent = (TextView)findViewById(R.id.lyricscontent);
Document doc = null;
String url = "http://api.chartlyrics.com/apiv1.asmx/SearchLyricDirect?artist="+message.toLowerCase()+"&song="+message2.toLowerCase();
LyricsContent.setText(url);
try {
doc = Jsoup.connect(url).get();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
它总是停我输入(字符串消息,串消息2)之后。 我已经与它:android.permission.INTERNET android.persmission.ACCESS_NETWORK_STATE />
而当我删除部分jsoup,它的作品。所以哪里出错?
后的堆栈跟踪。也似乎你在主线程中做网络操作,导致了'NetworkOnMainThreadException.'不要那样做。 – 2013-03-11 15:55:15
-1 A /不张贴堆栈跟踪。 B /没有定义“错误”C /没有搜索到异常。 – njzk2 2013-03-11 16:12:28