开发者

back button in android

开发者 https://www.devze.com 2023-01-19 05:54 出处:网络
Hello In my android application i have a video list screen,a buffering screen and a videoplayer screen.

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 butt开发者_JAVA百科on 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 :)


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 ;)


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);
}
0

精彩评论

暂无评论...
验证码 换一张
取 消