я нашел ответ на мой вопрос, просто объявите ниже, прежде чем onCreate
TimerTask scanTask;
final Handler handler = new Handler();
Timer t = new Timer();
напишите ниже на onCreate
scanTask = new TimerTask() {
public void run() {
handler.post(new Runnable() {
public void run() {
startScanning(); //here where u want to call the method
}
});
}};
t.schedule(scanTask, 300, 5000); // here is t.schedule( , delay, period);
вот оно