am having a button in the activity (button) ...if i click the button then
it fetches data from the server .if data is sucess then i has to show toast
as sucess...after if i click button while fetching data from the server if
net or wifi disconnect then it has to show (wifi or net disconnect
toast)...it sis working fine..


After disconnecting and connecting the wifi or net (not changing the
Activity.... just in the mobile making wifi disable and enable) ...now here
the wifi is enabled but iam getting the toast as wifi or net disconnected
..instead of the Sucess Message.....




here am attaching the code am getting data (emailResponse=sb.tostring)...

int bytes_read = 0;

StringBuilder sb = new StringBuilder();

while ((bytes_read = is.read(buffer, 0, buffer.length)) > 0) {
sb.append(new String(buffer, 0, bytes_read));
}

 emailResponse=sb.toString();


Log.i("response:", "R:" + sb.toString());


}
 catch (ConnectException e) {
 error=105;
 }
 catch (SocketException e) {
// TODO: handle exception
}
 catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
// e.printStackTrace();
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
// e.printStackTrace();
} catch (IllegalStateException e) {
// TODO Auto-generated catch block
// e.printStackTrace();
} catch (IOException e) {

error = 101;

// TODO Auto-generated catch block
// e.printStackTrace();
}

catch (NullPointerException e) {
// TODO: handle exception
}

catch (Exception e) {

error = 100;

Log.e(getClass().getSimpleName(), e.toString());
}


 return null;
}

@Override
protected void onPostExecute(String Result) {
// TODO Auto-generated method stub
super.onPostExecute(Result);
 if (emailResponse!=null) {
ACTIVITY_INSTANCE.dismissDialog(PROGRESS_DIALOG);

Toast.makeText(getApplicationContext(),"Sucess" ,Toast.LENGTH_SHORT).show();
}
  else if (error == 105) {
Toast.makeText(getApplicationContext(),"Wifi or net disconnect"
,Toast.LENGTH_SHORT).show();


}

}

}

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to