Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
是否可以有多个应用程序对象。如果是这样,我怎样才能将它们放在清单文件中。
谢谢你。
不能有多个应用程序对象。我认为您希望拥有跨应用程序可用的全局对象。执行此操作的最佳方法取决于您的特定用例。一种方法是继承 Application 类并将对象放在那里。我认为在 Application 类中拥有大对象没有任何不利之处,因为无论您将它们放在哪个类中,它们都会很大。它们要么是持久的,在这种情况下它们总是在内存中,要么他们不是。
另一种选择是单例。