和pressing后退按钮在安卓

和pressing后退按钮在安卓

本文介绍了在活动结束(问题)和pressing后退按钮在安卓的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我很迷茫使用完成()的活动,并使用回keypad.I按钮创造了许多活动,让对运动从一个活动到另一个我完成了最后一项活动。同时,我已经使用后退按钮在我的活动,这样我就可以回去(从我从哪里来)由pressing后退按钮,但是当我用键盘上的后退按钮我去的任何其他活动。我想它应该是我的活动的后退按钮问题就出现了。

I am very confused in using finish() for activity and using back button of keypad.I have created many activities so on moving from one activity to another I finish the last activity. And also I have used back button in my activity so I can go back (from where I came)by pressing back button but problem arises when I use keypad's back button I go to any other activity .I want it should work as my activity's back button.

我认为这可以通过使用onKeyListener和chekcing键盘的回退按钮,在那里我开始活动同我的活动的后退按钮来完成。我想知道是不是这样做的方式,或有一种方法比这更好的?

And I think this can be done by using onKeyListener and chekcing keypad's back buttons and there I start activity same as my activity's back button.I want to know is it right to do this way or there is a way better than this?

请帮

推荐答案

还有一个更好的方法:

您应该不叫完成()从一个活动到另一个时。如果需要内存,操作系统将清除它为你,当你preSS回来根据需要将工作。只要确保你的生命周期函数是正确的(你清理内存大块占用的东西,当你失去焦点等),你会成为一个更快乐codeR。

You should not call finish() when going from one activity to another. If the memory is needed, the OS will clear it for you, and when you press back it will work as needed. Just make sure your lifecycle functions are correct (you clean up big chunks of memory hogging stuff when you loose focus etc), and you'll be a much happier coder .

这篇关于在活动结束(问题)和pressing后退按钮在安卓的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 18:54