2016-04-24 89 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呢?可能是什麼原因

相關問題