0

I want to add some delay after calling an intent from a service. Ex: as shown below How can i do it?

Any Help would be appreciated.

if (yAccel > 500 || yAccel < -500)
{
    gMeasure = true;
    lockStatus = 1; //lock done;
    Intent intent = new Intent(this, ScreenLock.class);
    startActivity(intent);
    //delay for min 10 min
}
slavoo
  • 5,798
  • 64
  • 37
  • 39
Puru
  • 1
  • 1
  • what you basically want? delay after SCreenLock.class is opened or delay for 10 min and then call ScreenLock.class? – Hirak Chhatbar Jan 08 '15 at 07:42
  • check this..http://stackoverflow.com/questions/7965494/how-to-put-some-delay-in-calling-an-activity-from-another-activity – M S Gadag Jan 08 '15 at 07:43

1 Answers1

0

Have you tried with an Handler?

mHandler.postDelayed(new Runnable() {
            @Override
            public void run() {
                 Intent intent = new Intent(this, ScreenLock.class);
                 startActivity(intent);
            }
        }, 1000);
arthur_gg
  • 279
  • 1
  • 8
  • To arthur_gg, The above method will send this intent (screenlock.class) after 1000 ms, is not it ? My requirement is opposite of it.. I want screenlock.class to be sent and then wait for 10 min .. How can i do it ? Any help would be appreciated. – Puru Jan 08 '15 at 08:31
  • Oh ok I get it. You probably need to handle this in your ScreenLock activity. – arthur_gg Jan 08 '15 at 10:31
  • To @arthur_gg ... Any suggestion, How can i do it? My requirement is Once, I send screenlock.class (screen gets locked), I want to wait for 2-3 min in same condition. – Puru Jan 08 '15 at 13:10