tags:

views:

75

answers:

2

Hello In my android application i have a video list screen,a buffering screen and a videoplayer screen. As soon as the user clicks an item from videolist screen ,he is navigated to buffering screen and then to videoplayer. In the buffering screen i am using Async task and doing the loading process in on background process.

Now my issue is like the user if has selested a video then gets navigated to buffering screen.But if the user clicks back when he is in buffering screen then initially he is getting navigated to videolist screen but immediately after that again he is navigated to videoplayer screen.

What i would like to have is either the back button should be made disable in buffering or should prevent the player tostart if back is clicked.

Could you please let me know your valuable suggestions.

Thanks in advance :)

+1  A: 

If you want to simply intercept the back button pressed the Android Developers Blog has a simple example

  @Override
public void onBackPressed() {
// do something on back.
return;
}

You could have it just do nothing at all, if you wish ;)

x1886x
Please don't do this... it's very annoying for people who wish to cancel the buffering of a video (maybe they clicked the wrong button?). I'd uninstall your app if it blocked the back button.
SamStephens
Yes I agree, I meant to add to my answer that this would be a very 'cheap' way out of the problem. You would be better off stepping through your code and figuring out what is going wrong.
x1886x
A: 

I used to do it in a way:

@Override
public boolean onKeyDown(int keyCode, KeyEvent event)
{
    if (keyCode == KeyEvent.KEYCODE_BACK)
    {
       //do smth
    }
    return super.onKeyDown(keyCode, event);
}
barmaley