11

Is it possible to share resources across APK's? For example, can application A (in APK A) load an icon or layout view from application B (in APK B)?

jsmith
  • 4,847
  • 2
  • 32
  • 39

4 Answers4

24

You can make use of getResourcesForApplication

That way you can load whatever you want from other app package as long as you know at least the package name and the id or name of the resource to load.

As a side note, layouts cannot be loaded without further processing them with an XMLResourceParser because of possible id mismatches between your app package and the "guest" package.

Ander Webbs
  • 1,158
  • 1
  • 8
  • 11
1

Two different apps can share resources - images/ files,etc. if they are signed with same certificate. Please check android doc here

Andy1625
  • 31
  • 5
0

Only if it is delivered by content provider and the content serialized.

Pentium10
  • 204,586
  • 122
  • 423
  • 502
0

You can have two applications use the same Android library, which lets you share resources like activities, etc.

An Android library project is a development project that holds shared Android source code and resources. Other Android application projects can reference the library project and, at build time, include its compiled sources in their .apk files. Multiple application projects can reference the same library project and any single application project can reference multiple library projects.

Bryan Denny
  • 27,363
  • 32
  • 109
  • 125
  • 2
    Note, however, that library projects are build-time only. Once deployed on the device, the resources are duplicated across applications. – Pontus Gagge Nov 22 '10 at 14:04
  • You can avoid the duplication if the lib is installed on the system. Crosswalk offers this option for example, so the lib of 20MB can be installed once and re-used by any other apps on the system. – Kikiwa Dec 09 '16 at 10:28