0

I have the code below which is in ONCreate() method of the main activity and works fine. After moving to the next activity (B) which is a list view and then to activity (C ) which is the row selected from the listview and goes to sleep then the ScheduledExecutorService started in the main activity is not executing anymore .

Why is it not executing and how do I fix it? I am noob in Android .Please help me out.

Thanks in Advance .Really appreciate the help.

ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();
            executor.scheduleWithFixedDelay(new Runnable(){

                public void run() {


    //play audio file

    mp3.start();

                }

            }, 0, 60, TimeUnit.SECONDS);
4

1 回答 1

1

In order to cater the app running and the set sleeping scenario look in to using alarm manager with WAKELOCK... example : http://code4reference.com/2012/07/tutorial-on-android-alarmmanager/ and Alarm Manager Example

于 2013-02-12T10:50:32.993 回答