开发者

Implementing the "Go to Home" functionality in Android?

I want to implement a Home button in my Android App which will terminate the all the Activities but the first one. Instead of user pressing the Back button again and again, I want to give user a single button which will take him/her on the first (Home) Activity. 开发者_如何学JAVAPlease help how to implement it.


I dont have the SDK on this laptop to be sure about the syntax, but i think this is it.

Set up a listener for the "home" button, in the onClick() method:

Intent i = new Intent(ActivityYouAreOnNow.this,firstActivity.class);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(i);
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜