检查如果活动已呼吁结果

编程入门 行业动态 更新时间:2024-10-17 00:19:48
本文介绍了检查如果活动已呼吁结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想知道,如果它可以知道如果有些活动已经呼吁的结果,或只是开始使用startActivity。

I would like to know if its possible to know if some activity has been called for result or only started using "startActivity".

我需要控制这一点,如果它的要求的结果的行为将是不同的。

I need to control this, if its called for result the behaviour will be different.

在此先感谢!

推荐答案

当你的活动是由 startActivity开始只是() A getCallingActivity() 在目标活动的方法将返回空。

When your activity was started just by startActivity() a getCallingActivity() method in target activity will return null.

当它被称为 startActivityForResult()将返回调用活动的名字。

When it was called by startActivityForResult() it will return name of calling activity.

请参阅文档的 getCallingActivity () :

See Docs for getCallingActivity():

返回调用这个活动的活动的名称。这是   谁在的setResult数据()将被发送到。您可以使用此   信息来验证收件人允许接收   数据。

Return the name of the activity that invoked this activity. This is who the data in setResult() will be sent to. You can use this information to validate that the recipient is allowed to receive the data.

请注意:如果调用活动没有期待的结果(这是它     没有使用 startActivityForResult(意图,INT)的形式,     包括:请求code),然后调用包将为null。

Note: if the calling activity is not expecting a result (that is it did not use the startActivityForResult(Intent, int) form that includes a request code), then the calling package will be null.

返回

该活动的单元名,将得到您的答复,或者如果没有则为null。

The ComponentName of the activity that will receive your reply, or null if none.

更多推荐

检查如果活动已呼吁结果

本文发布于:2023-11-25 23:04:18,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1631702.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!