清单中的Android抽象活动 [英] Android abstract activity in manifest

查看:78
本文介绍了清单中的Android抽象活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于我的应用程序,我将创建各种抽象类,以扩展android.app.Activity和android.app.Service类.

For my application I am going to create a variety of abstract classes that extend the android.app.Activity and android.app.Service classes.

  • 当我对抽象类进行子类化时,如何将它们添加到android清单中?
  • 我是否需要将抽象类和子类都添加到清单或仅将子类中添加?
  • 它们需要放在同一个包裹中吗?

推荐答案

您将最终的子类作为常规的活动/服务"添加到清单中;抽象类不需要在那里,因为清单只是一个查找,因此系统知道要响应Intent启动哪个类

You add the final subclasses to the manifest as regular Activities/Services; the abstract classes don't need to be there, as the manifest is only a lookup so the system knows which class to launch in response to an Intent

如果包"是指Java包(例如com.mycompany.whatever),则否,在创建子类时只需添加相关的导入(或使用全限定名)即可.

If by 'package' you mean Java package (e.g. com.mycompany.whatever), then no, just add the relevant import (or use the fully qualified name) when creating the subclass.

如果打包"是指APK,那么是的,抽象库应该包含常规代码,因为虽然可以在APK之间进行调用,但是这取决于您可以实例化的类.如果要重新使用这些抽象类,则可以将其拆分为一个Android库项目-Android库项目本质上是共享源,而不是传统的Java jar.

If by 'package' you mean APK, then yes, the abstract base should be in there with the regular code, as although it is possible to call between APKs, you this relies on classes you can instantiate. You can split the abstract classes out into an Android library project, if they're going to get re-used - Android library projects are essentially shared source, rather than traditional Java jars.

让我知道您是否需要更多详细信息,因为这是一个广泛的问题,我希望答案大小可管理

Let me know if you need more details on any of this, as this is quite a broad question, and I'd like to keep the answer size managable

这篇关于清单中的Android抽象活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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