按钮回去appliaction [英] Button to go BACK in appliaction

查看:235
本文介绍了按钮回去appliaction的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要code一键返回到主应用程序的活动。

I need to code a button to go BACK to the main application activity.

public void onGotoMainActivity(View View)
    {
         Intent intent = new Intent(View.getContext(), MainActivity.class);
         this.startActivity(intent);
    }

主要活动已启动,并没有被破坏。因此,我不认为这将是一个新的意图也不应该启动活动?应该不是它只是调用的主要活动回焦点?

The Main activity is already started and has not been destroyed. So I don't think this would be a "new" intent nor should it "start activity"? Shouldn't it merely call the main activity back to focus?

推荐答案

您也可以使用此功能。

Intent intent = new Intent();
setResult(RESULT_OK, intent);
finish();

这篇关于按钮回去appliaction的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆