开发者

Music doesnot stop after pressing backkey

I have an activity A which invokes Activity B on Button Click,and a Button click on Activity B invokes Class C. When button is clicked in Activity B , B calls a static method in Class C which passes its reference as one of the argument to method in C and other argument is path to the sound file that needs to 开发者_运维问答be played. Once control reaches class C , Audio is played. But when Backkey is pressed Audio doesnot stop it continuous to play. How can I make the Audio to stop when BackKey is pressed. More over when Backkey is pressed control is coming to Activity A instead of Activity B. Can any one help me in solving this issue?

class activityA extends Activity

{ startIntent(ActivityB) on ButtonPress

}

class ActivityB extends Activity

{ classc.playAudio(ActivityB.this,audiopath);

}

class c

{ playAudio(Activity a, audiopath)

{ sound code to play audio is done here.

}

}


Use this in C activity , trap back key when going back from activity C

@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if ((keyCode == KeyEvent.KEYCODE_BACK)) { //stop your music here } return super.onKeyDown(keyCode, event); }

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜