-2
私は分割しようとすると、私のアプリをクラッシュさせますが、分割されたコード行がなければ、私のアプリは正常に実行され、私の応答を返します。区切り文字が "|"のサーバーここでのコードは次のとおりです。do not background split in working
protected String doInBackground(String... params) {
String type= params[0];
String login_url="somelink.com/somelink.php";
if(type.equals("login")){
try {
String username= params[1];
String password= params[2];
URL url= new URL(login_url);
HttpURLConnection httpURLConnection = (HttpURLConnection)url.openConnection();
httpURLConnection.setRequestMethod("POST");
httpURLConnection.setDoOutput(true);
httpURLConnection.setDoInput(true);
OutputStream outputStream = httpURLConnection.getOutputStream();
BufferedWriter bufferedWriter= new BufferedWriter(new OutputStreamWriter(outputStream, "UTF-8"));
String data=URLEncoder.encode("n", "UTF-8") + "=" + URLEncoder.encode(username, "UTF-8");
data+="&" + URLEncoder.encode("p", "UTF-8") + "=" + URLEncoder.encode(password, "UTF-8");
bufferedWriter.write(data);
bufferedWriter.flush();
bufferedWriter.close();
outputStream.close();
InputStream inputStream = httpURLConnection.getInputStream();
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream,"iso-8859-1"));
String result="";
String line="";
while((line = bufferedReader.readLine()) != null){
result += line;
}
String[] words=result.split("\\|");
StringBuilder ch=new StringBuilder();
ch.append(words[0]);
String check=ch.toString();
bufferedReader.close();
inputStream.close();
httpURLConnection.disconnect();
return check;
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
return null;
}
正確に何が起こっているのかをログで確認できますか?いいえ、どのような例外がスローされますか? – realharry
それは問題です、私のavdは私のコンピュータで動作しないので、私のアンドロイドデバイスを使用してアプリケーションをテストしています – vikki
あなたは簡単にあなたのデバイスに 'adbを介してログインすることができます知っている。あなたはデバイス上でlogcatを見ることができます。 – realharry