게임을 하나만들었는데요
게임이 다끝나면 PopupWindow가 뜨면서 점수와 이름정보를 DB로 날리도록 하였습니다.
파일전송은 AsyncTask를 상속해서 해보기도하고 그냥 함수로만들어서 해보기도 하였으나
파일전송을못하고 예외처리로 넘어가네요 ㅠ
파일전송은 GameView에서 처리됩니다.
*파일전송코드
try { //203.246.112.69
URL url = new URL(""http://*********************/Android_ranking_upload.php");
HttpURLConnection httpURLCon = (HttpURLConnection)url.openConnection();
//kmu20!!
Log.v("Jang", "test");
httpURLCon.setDefaultUseCaches(false);
httpURLCon.setDoInput(true);
httpURLCon.setDoOutput(true);
httpURLCon.setRequestMethod("POST");
httpURLCon.setRequestProperty("content-type", "application/x-www-form-urlencoded");
StringBuffer sb = new StringBuffer();
sb.append("name").append("=").append(name).append("&");
sb.append("score").append("=").append(score).append("&");
sb.append("time").append("=").append(time);
PrintWriter pw = new PrintWriter(new OutputStreamWriter(httpURLCon.getOutputStream(),"EUC-KR"));
pw.write(sb.toString());
pw.flush();
BufferedReader bf = new BufferedReader(new InputStreamReader(httpURLCon.getInputStream(),"EUC-KR"));
StringBuilder buff = new StringBuilder();
String line;
while((line = bf.readLine()) != null){
buff.append(line);
}
}catch (Exception e) {
Log.v("Jeewon", "Sending Error");
}