After some research and practice, I have observed that we can access Resources of other Apps using PackageManager like
Resources resources = getApplicationContext().getPackageManager().getResourcesForApplication(appPackageName);
but merely accessing Resources
is not sufficient. We need Ids for every Resource component like Drawables, layouts,Strings etc etc... to access them from Resources.
I have searched in SO and struggled a lot myself about how to get Resource Ids of other Apps but didn't get proper solution. I have seen in SO, some people suggested to use methods like
resources.getIdentifier(String name, String defType, String defPackage);
resources.getValue(String name, TypedValue outValue, boolean resolveRefs);
resources.getValue(int id, TypedValue outValue, boolean resolveRefs);
but don't have Idea how to use them.
I need to access Resources(Drawables, Strings, Layouts...) of other Apps.
Help me in this concern. Any help would be greatly appreciated...
thank you all and sorry for my english...
Thanks for your question, I can able to access via following code. It is working fine..
String lAppPkg = "com.example.sharedlogos";
resources = getApplicationContext().getPackageManager()
.getResourcesForApplication(lAppPkg);
int lID = resources.getIdentifier( mID, "drawable",
lAppPkg);
mImage.setBackground(resources.getDrawable(lID));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With