class SendPostAsyncTask extends AsyncTask<String, Void, String>
{
@Override
protected String doInBackground(String... params) {
// TODO Auto-generated method stub
String content = executeClient(params[0], params[1]);
Log.d("doInBackground","doInBackgrounddoInBackground");
return content;
}
@Override
protected void onPostExecute(String result)
{
// TODO Auto-generated method stub
super.onPostExecute(result);
//Log.d("~~~~~onPostExecute결과~~~~~",result);
}
public String executeClient(String content, String tel)
{
.
.
.
생략
//0422
try
{
UrlEncodedFormEntity entity = new UrlEncodedFormEntity(
valuelist, "UTF-8");
httpPost.setEntity(entity);
HttpResponse hres = httpclient.execute(httpPost);
HttpEntity hentity = hres.getEntity();
if (hentity != null)
{
str="";//초기화
responseStr = EntityUtils.toString(hentity);
Log.d("-------responseStr------", responseStr); // 결과값출력
str += responseStr;
String sendOk = "\"success\": 1,";
if(str.contains(sendOk))
{
responseResult(1,responseTime);
}
else
{
responseResult(0,responseTime);
}
}
return EntityUtils.getContentCharSet(entity);
}
catch (ClientProtocolException e)
{
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}
return null;
}
}
public void responseResult(int check, String date) //성공실패여부,날짜
{
if(check==1)//성공
{
Log.d("성공했음","성공했음1");
mBluetoothLeService.writeCharacteristic(mWriteCharacteristic, data);
}
}
위와같은 코드로 일단 서버에서의 결과값은 받아왔습니다. 성공했는지 실패했는지 확인가능하구요.
결과값에 따라서 if문으로 나눈 후, 그 값을 블루투스 기기로 전송하고싶은데, writeCharacteristic에서
에러가 발생합니다. 에러 문구는 다음과 같습니다. 따로 일련의 작업을 해야하는지요?
밑의 로그에서 메인 2546에러가 writeCharacteristic 부분입니다.
