java - How to stop a running thread under following condition in ANDROID -



java - How to stop a running thread under following condition in ANDROID -

in app when user clicks on spell button play sound read outs letters of word displaying each letters. implemented successfully!.

and used swipe gesture alter word. if user swipes screen word should displayed. , implemented successfully!!

problem: while sound playing if user swipes sound should stop , next word shold displayed.(i guess running thread should stopped).

how can that? solution?

code outlines:

public class birdsactivity extends activity implements onclicklistener{ //on createmethod*(){ . . //on spell button click run thread play sound , draw text new drawletter("alphakids").start(); // initiate gesture detection } class drawletter extends thread { string tempname=names[position]; string b=""; int i=0; public drawletter(string str) { super(str); } public void run() { (int = 0; < names[position].length(); i++) { runonuithread(new runnable() { public void run() { txtfrontname.settext(b); } }); mplayvoice = mediaplayer.create(birdsactivity.this, malphabetssound[letterposition]); mplayvoice.start(); seek { sleep(500); mplayvoice.release(); } grab (interruptedexception e) {} }} . . . // gesture detection class @override public boolean onfling(motionevent e1, motionevent e2, float velocityx, float velocityy) { //if valid swipe performed { //i want stop(or distroy) above thread here } } }

i guess don't have destroy thread self. stop music mplayvoice.stop(); since variable declared in uithread ... can accessed in uithread , can stop player there. in handler.

java android multithreading media-player

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

intellij idea - Update external libraries with intelij and java -

javascript - send data from a new window to previous window in php -