2016-04-24 50 views
0

您认为此代码有何错误? 我使用这个类:https://github.com/btouchard/HttpData/blob/master/README.md无法执行活动的方法httpdata

错误:

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

如果'Log.i()'调用抛出'Exception',那么'html'可能是'null'。 –

回答

0

试一试捕捉异常,如果String html变为null呢?可能是什么原因

相关问题