0

誰でも、私を助けてください。try ステートメントでエラーが発生しました。警告には、finally ステートメントをそこに配置する必要があると書かれていますが、警告はまだそこにあります。すでに新しいページにコピーして再試行しましたが、それでも同じエラーが発生しました。

private void receiveMsg() {
    Bundle bundle = this.getIntent().getExtras();
    final String param1 = bundle.getString("keyCourseId");
    final String param2 = bundle.getString("keyChatId");
    final String param3 = bundle.getString("keyUserId");
    final String param4 = bundle.getString("keyChatMsgsId");
    // TODO Auto-generated method stub

    linkurl = new Koneksi(this);
    SERVER_URL = linkurl.getUrl();
    SERVER_URL += "/mobile/ChatReceive.php?idc="+param1+"&idch="+param2+"&idu="+param3+"&idcm="+param4;
    HttpClient httpClient = new DefaultHttpClient();
    HttpPost httpPost = new HttpPost(SERVER_URL);
    ArrayList<NameValuePair> param = new ArrayList<NameValuePair>();{
        try {
           //add parameter
            httpPost.setEntity(new UrlEncodedFormEntity(param));

            HttpResponse httpRespose = httpClient.execute(httpPost);
            HttpEntity httpEntity = httpRespose.getEntity();

            //read content
            InputStream in = httpEntity.getContent();
            BufferedReader read = new BufferedReader(new InputStreamReader(in));

            String content = "";
            String message = "";

            while((message = read.readLine())!=null){
               content += message;
            }
           Log.d("ADBUG", "content: "+content);


            //json
            if(!content.equals("null")){

               try {
                  JSONArray jArr = new JSONArray(content);
                  String chatname="";
                  String messages="";

                  for(int i=0;i<jArr.length();i++){
                     JSONObject jObj = jArr.getJSONObject(i);

                     String name = jObj.getString("name");
                     String msg = jObj.getString("msg");

                     chatname += name+"\n";
                     messages += msg+"\n";
                  }


                  messagesContainer.setTag(messages);
                  friendLabel.setText(chatname);

        }catch (Exception e) {


            showMessage(message, false);
        }
    } //<- in here the warning says must put finally statement but still got red mark
}
});
}
4

1 に答える 1