Getting resources of another Application

后端 未结 5 1333
别跟我提以往
别跟我提以往 2020-12-03 05:43

Assume I\'ve got 2 Application A and B.

I want to access resources (drawables, images, strings) of an B application from A application. How would I do that?

<
5条回答
  •  执笔经年
    2020-12-03 06:41

    If you are the developer of both applications then the right approach would be, as othes noted, to create an Android library project and share it between apps.

    Nevertheles, you can still access resources from another app, even if this is not your app:

    Resources res = context.getPackageManager().getResourcesForApplication("com.example.foo")
    

提交回复
热议问题