So I’ve created a WebView and set the content to an html string like so (This gets called when a user presses a ListView Item):
String html = "<html>" +
"<body style=\"padding:0px;margin:0px;border:0px none;\">" +
"<embed type=\"application/x-shockwave-flash\"" +
" id=\"stratos_embed\"" +
" width=\"100%25\" height=\"100%25"\"" + //%25 = % (escaped)
" src=\"myVideoSource.swf\"" +
" pluginspage=\"http://www.macromedia.com/go/getflashplayer\"" +
" allowfullscreen=\"true\" allowscriptaccess=\"always\">" +
"</embed>" +
"</body></html>";
Intent intent = new Intent(getBaseContext(), VideoActivity.class);
intent.putExtra("VIDEO_CONTENT", html);
this.startActivity(intent);
I can watch the flash video in the web video and everything’s dandy.
The problem is when I press the back button the video continues to play (I can hear the audio) but I don’t want it to.
I’ve read about using finish() to kill the activity but I’m not sure where to use it. I put it in my VideoActivity class like so:
@Override
public void onPause(){
finish();
}
But when I press the back button, an error occurs and the app is forced closed.
For Honeycomb+ targets, you can add calls to the WebView’s
onPause()andonResume()in your activity’sonPause()andonResume():Alternatively (and since those methods are hidden for earlier targets), the following should work too: