开发者

Button Back in android?

I have a question. Is it ok to override the onBackPressed method on Android app? In my android app I take photos using the android camera device.After that the user can see view the photo and if he likes it he can submit it to a photo contest.If he doesn't like it he can retake the photo. The problem is with the backbutton of the android device.When the user views the photo and press the back button he can see the previous photo taken.And I don't want that!!!the photos are saved on SDcard.And onc开发者_StackOverflowe a photo is taken the previous one ie replaced by the new one...and still by pressing back I can see the prevois photo.Any idea


If you don t need your backbutton in other part of your activity, it is ok to override it.

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


Yes it is considered ok to override the back button, and other buttons.

You can read a good article about it here: http://android-developers.blogspot.com/2009/12/back-and-other-hard-keys-three-stories.html


Be careful. You need to make sure the process flow is intuitive to the user, but yes you can change the flow.

Read this page which covers various options available for manipulating how it works http://developer.android.com/guide/practices/ui_guidelines/activity_task_design.html


The application flow isn't very clear to me, but it sounds like you can fix the problem in two seperate ways. First is to override the onBackPressed method. But then you really have to think about how the user can get out of the application while not using the home button. Second option is to not store the activity in the activity stack, see here

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜