Android的 - 请求code中的onCreate [英] Android - Request code in onCreate

查看:188
本文介绍了Android的 - 请求code中的onCreate的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是否能访问请求,code活动在其的onCreate()方法获得?

can I access the requestCode an activity received in its onCreate() method?

我需要它来理解,如果它是一个新的或修改操作。

I'd need it to understand if it is a "new" or "modify" operation.

推荐答案

假设你创建活动的 A

活动的生命周期是这样的: A.onCreate() - GT; A.onStart() - > A.onResume()

The activity lifecycle goes like this : A.onCreate() -> A.onStart() -> A.onResume()

然后调用活动的 B 从活动的 A 。你想活动的 B 给你送回来的结果。

Then you call activity B from activity A. You want activity B to send you back a result.

活动的生命周期是这样的: A.onPause - > B.onCreate - > B.onStart() - > B.onResume() - > A.onStop()

The activity lifecycle goes like this : A.onPause -> B.onCreate ->B.onStart()-> B.onResume()->A.onStop()

B 已完成其工作,它将发送一个结果,并摧毁了自己: B.onDestroy() - > A.onResume() - > A.onActivityResultBack()

Once B has done its job, it will send a result and destroyed itself : B.onDestroy()->A.onResume()-> A.onActivityResultBack()

我的整个观点是,该活动的 A 不回去的onCreate !所以,除非你有一个属性请求,code在你的 activityA.java 的文件,你不能访问它在其的onCreate 方法。

My whole point is that the activity A does not go back to onCreate ! So unless you have an attribute requestCode in your activityA.java file, you can not access it in its onCreate method.

这篇关于Android的 - 请求code中的onCreate的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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