如何处理在android的多个应用程序类多个、如何处理、应用程序、android

2023-09-12 08:03:51 作者:个性小丑△

我开发一个原生的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"
 >
 
精彩推荐
图片推荐