P
P
Pavel Dmitriev2015-03-20 00:33:45
Java
Pavel Dmitriev, 2015-03-20 00:33:45

Why does the listener not work on a tablet and works on a phone?

I have a thread that starts autosound after the start of the activity.
For a phone it looks like this

void Thread(boolean b){
        new Handler().postDelayed(new Runnable() {  
            public void run() {                 
                while (!stopRequested) {
                    if(MainScreen.tgbutton.isChecked() == false) {  
                        mSoundPool.setOnLoadCompleteListener(new OnLoadCompleteListener() {
                            public void onLoadComplete(SoundPool mSoundPool, int sampleId, int status) {
                                mSoundPool.play(mSlovo, 1, 1, 1, 0, 1);
                                }
                            });

                        stop(); 
                        } 
                    else {
                        stop();
                        }
                    }
                }           
            public void stop () {
                stopRequested = true;
                }
            }, 100);
    };

For a tablet
void Thread(boolean b){
    new Handler().postDelayed(new Runnable() {  
        public void run() {                 
            while (!stopRequested) {
                if(MainScreen.tgbutton.isChecked() == false) {                  
                    mSoundPool.play(mSlovo, 1, 1, 1, 0, 1);
                    stop(); 
                    } 
                else {
                    stop();
                    }
                }
            }           
        public void stop () {
            stopRequested = true;
            }
        }, 100);
};

If I add a listener, then the sound disappears on the tablet, if I remove it, then it disappears on the phone. What could be the reason?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question