我什么时候应该实例化Activity类? [英] When am I supposed to instantiate Activity class?
本文介绍了我什么时候应该实例化Activity类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我看到可以通过new
关键字实例化Activity
.
I see that it is allowed to instantiate Activity
via new
keyword.
new MainActivity();
这样做时,我立即可以访问其所有字段,事件等.
When I do that, I immediately get access to all its fields, events, etc.
那么,我何时应该以这种方式实例化某些Activity
类?我的意思是在哪种情况下.
So, when should I ever need to instantiate some Activity
class in such a way? I mean in which situations.
谢谢.
推荐答案
从不.创建Activity
实例应始终由ActivityManager
单独处理,具体取决于您发送的Intent
项目.
Never. Creating Activity
instances should always be handled by the ActivityManager
alone based on the Intent
items you send.
这篇关于我什么时候应该实例化Activity类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文