Search code examples
androidandroid-emulatorhttp-live-streamingandroid-4.0-ice-cream-sandwich

how to kill the activity streaming HLS on Android4


I made an app which which launches with an Activity which is essentially a list of videos. When the user clicks on one of the options that video is streamed via HLS(Apple's http live streaming) in another Activity. Now when I press the back button, home button etc, the activity is not finished and the video plays in the background. All i want to do is whenever somebody navigates out of the app for whatever reason, i want to kill that activity. How can that be done.

code i use for hls streaming:

MediaPlayer m = new MediaPlayer();
        try{
            m.setDataSource("http://devimages.apple.com/iphone/samples/bipbop/gear1/prog_index.m3u8");
        m.prepare();
        m.start();}
        catch(Exception e){}

thanks, Jay


Solution

  • for killing an activity you can do

    yourClassName.this.finish();
    this.finish();
    finish();
    

    hope this helps