cthr
2
Q:

call function after specific time java android

new java.util.Timer().schedule( 
        new java.util.TimerTask() {
            @Override
            public void run() {
                // your code here
            }
        }, 
        5000 
);
3
Runnable mToastRunnable;
Handler mHandler = new Handler();



  //create runnable for delay
       mToastRunnable = new Runnable() {
            @Override
            public void run() {
                Toast.makeText(MainActivity.this, "This is a delayed toast", Toast.LENGTH_SHORT).show();
                mHandler.postDelayed(this, 3000000);
                getlocation();
            }
        };
//start
 mToastRunnable.run();

//stop
 mHandler.removeCallbacks(mToastRunnable);
0

New to Communities?

Join the community