I'm working on an app with a WebView but the website has music in the background. I have code when the back button is pressed will go back to previous page until it can go back anymore and will go back to main menu. Problem is that when it goes back to main menu, the music does not stop and I need it to stop. Sorry only a beginner. Any help would be awesome!
Code:
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if(event.getAction() == KeyEvent.ACTION_DOWN){
switch(keyCode)
{
case KeyEvent.KEYCODE_BACK:
if(myWebView.canGoBack() == true){
myWebView.goBack();
}else{
this.finish();
}
return true;
}
}
return super.onKeyDown(keyCode, event);
}
Xml
<WebView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/webView"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />