在我的android登錄活動,當用戶輸入電子郵件和密碼的請求去servlet,然後servlet檢查它在database.If電子郵件和密碼匹配,然後它發送迴應回來如下所示。如何比較out.writeObject(「」)與字符串
out.writeObject("matches");
這裏走出來的是
ObjectOutputStream out = new ObjectOutputStream(response.getOutputStream());
現在從我的Android登錄活動我想打開另一個活動,如果電子郵件地址和密碼matches.Here是代碼
@Override
protected void onPostExecute(String result) {
// TODO Auto-generated method stub
Toast.makeText(getApplicationContext(), result, Toast.LENGTH_LONG).show();
System.out.println(result);
if(result.equals("matches"))
{
System.out.println("valid user");
Intent intent = new Intent(Login.this,Photos.class);
startActivity(intent);
}
}
但我不能進入在if條件中。我打印顯示匹配的String結果的值,並且我的Toast消息在電子郵件和密碼匹配時也顯示匹配。但是,儘管result.equals(「matches」)不滿足。並且I我也沒有收到任何錯誤。 我知道我在某處犯錯,但我不知道在哪裏。請幫助我。 我也嘗試
if(result.toString().equals("matches"))
但不能得到output.Please幫我
也許你有一些非打印字符。 – 2014-11-20 22:06:18
但是System.out.println(結果)只在條件爲 – 2014-11-20 22:07:22
的上面打印匹配不可打印的定義意味着你不會在'println()' – 2014-11-20 22:08:09