All power is within you, you can do, anything and everything. believe in that do not believe that you are weak. You can do any thing and everything, without even the guidance of any one. Stand up and express the divinity within you. Within each of you there is the power to remove all wants and all miseries - Vivekanada

Wednesday, January 12, 2011

How to access resources from other application (.apk)

We might be interested in accessing the resources of other application. Or inflate a particular view from other applications layout xml file.In this post, we will discuss more about how to achieve this.

1 - What ever we need to access (resources or layout), we need two main things from other application .

1 - R.java. Required for you during compilation time.

2 - Application's context. Resources needs to be inflated with the correct application's 'Context' instance.Else at runtime the prog will crash.

2 - The app1(.apk) needs to be installed on the device in order for you to create app1's context instance and then inflate the resources / layouts.

app1 :------Create a an android application with package (com.android.app1 ) which contains resources you want to expose to others.

AndroidManifest.xml:

Manifest file doesnt have any entry for activity or application tags. it just says, under which package the resources will be present.

About me

Working as a senior android engineer @ NativeX, US. From southern part of INDIA. With 8+ years of experience in software industry, trying to learn and explore more. Contact me if you felt i am of helpful in some of your queries and knowledge sharing in Android...!!