如何处理在android的多个应用程序类 [英] how to handle multiple application classes in android

查看:121
本文介绍了如何处理在android的多个应用程序类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发一个原生的Andr​​oid应用程序,其中我试图使用 2的开源库。问题是这两个库都在各自的图书馆使用应用程序类。应用程序代码下的:名机器人他们使用的注册这些类在各自的源$ C ​​$ C清单文件。 问题是,如何处理这样的场景,因为我们知道,只是一个标签可用于内部清单文件。 我们可以注册/实例应用程序类中的code,所以我们只提一个库的标识,第二使用code /务实。 还是有什么其他选择。 请分享您的意见/建议。 先谢谢了。

I am developing a native android application, in which I am trying to use 2 open-source libraries. Problem is both the libraries are using Application Class in their respective libraries. They are registering these classes in their respective source code in manifest file using "android:name" under the application tag. Question is how to handle such a scenario, since as we know, only ONE tag can be used inside manifest file. Can we register/instantiate the Application Class in the code, so that we mention only ONE library in tag and the second using code/pragmatically. OR are there any other alternatives. Please share your comments/suggestions. Thanks in advance.

推荐答案

您需要实现多级继承来解决这种情况。

You need to implement Multilevel inheritance to resolve this scenario.

这是您的方案

public Lib1Application extends Application{

}

public Lib2Application extends Application{

}

public YourApplication extends Application{

}

如何解决此问题?

public Lib1Application extends Application{

    }

    public Lib2Application extends Lib1Application{

    }

    public YourApplication extends Lib2Application{

    }

终于在mainfest.xml

<application
        android:name="com.your.packagename.YourApplication"
        android:icon="@drawable/ijoomer_luncher_icon"
        android:label="@string/app_name"
 >

这篇关于如何处理在android的多个应用程序类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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