您认为这段代码有什么问题? 我正在使用这个课程:https://github.com/btouchard/HttpData/blob/master/README.md
错误:
java.lang.IllegalStateException: Could not execute method of the activity
Location of error: Log.i line!
感谢您的帮助。 我想这是一个基本的解决方案,但我无法找到它。
public class Formulaire extends Activity {
EditText msgTextField;
Button sendButton;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.form);
//make message text field object
msgTextField = (EditText) findViewById(R.id.msgTextField);
//make button object
sendButton = (Button) findViewById(R.id.sendButton);
}
public void send(View v) {
//get message from message box
try {
String MonURL = "http://www.davidmarchioni.fr/glopper/test.txt";
HttpData request = new HttpData(MonURL);
request.header(MonURL);
String html = request.asString();
Thread.sleep(2600);
Log.i("OK >> ", html);
Toast.makeText(getApplicationContext(), html, Toast.LENGTH_SHORT).show();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
答案 0 :(得分:0)
尝试捕获异常,如果String html为空怎么办?可能是什么原因