I am program Music Play in WebView getting link from my website.
I want my WebView activity kept with Status Bar Notification when user pressed Home Button. Please help give me some way.
My Code in WebView:
public class playlist extends Activity {
private WebView mWebView;
MediaPlayer myMediaPlayer;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.playlist);
mWebView = new WebView(this);
mWebView = (WebView) findViewById(R.id.playlist);
mWebView.setWebViewClient(new myWebClient());
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.getSettings().setAllowFileAccess(true);
mWebView.getSettings().setPluginsEnabled(true);
mWebView.getSettings().setBuiltInZoomControls(true);
mWebView.loadUrl("http://www.mp3skull.com/justin_bieber.html");
}
public class myWebClient extends WebViewClient
{
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
// TODO Auto-generated method stub
super.onPageStarted(view, url, favicon);
}
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
// TODO Auto-generated method stub
view.loadUrl(url);
return true;
}
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if ((keyCode == KeyEvent.KEYCODE_BACK) && mWebView.canGoBack()) {
mWebView.goBack();
return true;
}
return super.onKeyDown(keyCode, event);
}
@Override
public void onPause() {
mWebView.setVisibility(View.GONE);
mWebView.destroy();
super.onPause();
}
}
This code when user press Home Button the Music also stop because of Voide onPause(), but I need keep music playing on Status Bar Notification with correct activity. Please help me.
Regards, Virak