How to set time check on login?
<p>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 ?</p>

<p>Login button:</p>

<pre><code>        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();
}
</code></pre>

<p>Here i want to check the difference Here:</p>

<pre><code>SharedPreferences myPrefs = Login.this.getSharedPreferences("myPrefs",MODE_WORLD_READABLE);
            time = myPrefs.getLong("starttime", System.currentTimeMillis());
if("ok".equalsIgnoreCase(status) &amp;&amp; (System.currentTimeMillis() - time) &gt; 3000)
{
    \\Code
}
else
{  
    Alert
}
</code></pre>
