I want to set a time check of 30 Seconds. Basically what i want is i will call a webservice for login and after clicking the login button i want to check if i am not getting a status OK within 30 seconds i want so show a alert tha please try again. How to set this ?
Login button:
logbtn.setOnClickListener(new OnClickListener()
{
public void onClick(View v)
{
start = System.currentTimeMillis();
SharedPreferences myPrefs = Login.this.getSharedPreferences("myPrefs",MODE_WORLD_READABLE);
SharedPreferences.Editor prefsEditor = myPrefs.edit();
prefsEditor.putLong("starttime", start);
prefsEditor.commit();
}
Here i want to check the difference Here:
SharedPreferences myPrefs = Login.this.getSharedPreferences("myPrefs",MODE_WORLD_READABLE);
time = myPrefs.getLong("starttime", System.currentTimeMillis());
if("ok".equalsIgnoreCase(status) && (System.currentTimeMillis() - time) > 3000)
{
\\Code
}
else
{
Alert
}