如何找到从当前活动在android的打开最后一个活动? [英] How to find last activity from which current activity is opened in android?

查看:93
本文介绍了如何找到从当前活动在android的打开最后一个活动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个活动这可以从更多4个或5个不同的活动开,所以我可以从中找到活动我目前的活动就叫做...

I have one activity which can be open from more 4 or 5 different activity so i can find from which activity my current activity is called...

如果任何想法,请帮助我..

If any idea please help me..

推荐答案

您可能需要额外添加到您用来启动该活动以指示意图是从还是什么的要求是未来的意图。

You might want to add extras to the intent you use to start the activity to indicate where the intent is coming from or what the request is.

例如:

Intent intent = new Intent(this, OtherActivity.class);
intent.putExtra("caller", "MainActivity");
startActivity(intent);

,然后你的 OtherActivity 可以检测出来电,在其的onCreate

and then your OtherActivity could detect the "caller" in its onCreate:

String caller     = getIntent().getStringExtra("caller");
Class callerClass = Class.forName(caller);

这篇关于如何找到从当前活动在android的打开最后一个活动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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