How to block back to previous screen event?

Put your problem here if it does not fit any of the other categories.

How to block back to previous screen event?

Postby Jay » Tue Apr 14, 2009 11:59 am

Hi comunity ,

I need to block the back key event to return to previous screen , how could i meet this requirment??

Please help .

Thanks .
Jay
Jay
Developer
Developer
 
Posts: 28
Joined: Wed Apr 23, 2008 3:51 am

Top

Postby WarrenFaith » Tue Apr 14, 2009 12:05 pm

I am not sure, but I think there is no way to do it. It is like the back button on your webbrowser....
You will disturb the usability the user is used to. So even if you find a way to do it, be careful....
WarrenFaith
Moderator
Moderator
 
Posts: 227
Joined: Fri Mar 13, 2009 10:59 am
Location: Berlin, Germany

Postby padde » Tue Apr 14, 2009 2:35 pm

If you dont want the user to go back to the previous activity then just finish() the previous
activity instead of blocking some deep OS rooted functions.
There is no scenario that i could offhanded think of where such a mechanism is the only way to go.

Greets
Padde
padde
Master Developer
Master Developer
 
Posts: 443
Joined: Wed Apr 08, 2009 4:52 pm

Postby Jay » Wed Apr 15, 2009 2:48 am

Thank you guys ,I solved this problem .

Just override the onKeyDown Event like :


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

If you dont want to block you just return the default handling .

Best Regards ,
Jay
Jay
Developer
Developer
 
Posts: 28
Joined: Wed Apr 23, 2008 3:51 am

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 19 guests