这是我的代码的一部分:
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 的部分时,它可以工作。那么哪里出了问题?