Reputation: 1278
I've built a semi-push service (checkins for notifications from a centralized http server) that I'd like to distribute to a few friends and customers, so they can easily add push-like notifications to their apps without much hassle.
I've gotten far enough to package the JAR and include it in a few of my other projects, but now I'm hitting a brick wall with regard to resource packaging --
R.drawable.goldstar
, and once by referencing resources.getIdentifier('goldstar', 'drawable', 'com.com.pushnotify')
getIdentifier('goldstar', 'drawable', 'com.com.pushnotify')
.How can I distribute a JAR with drawable resources, and have them appear in the dependent apps? Apps including my JAR never need to access the icons I am distributing, only my own code does.
Despite much nay-saying on in the search results I find, I am certain this is somehow possible, because a) my JAR file grows when I add new images, and b) I've included JAR files that come with icons before (Airpush does this, as does UrbanAirship).
Thanks in advance!
Upvotes: 2
Views: 1911
Reputation: 9167
This is not exactly what you were asking for but here is an interesting option anyway :
Instead of getIdentifier('goldstar', 'drawable', 'com.com.pushnotify')
use getIdentifier('goldstar', 'drawable', getApplicationContext().getPackageName())
And distribute the images/resources as a .zip to be unzipped, installed and compiled with the target app (the one that will use your shared .jar)
And don't include the images in the .jar.
This is not tested but that should work.
Upvotes: 0
Reputation: 1007584
How can I distribute a JAR with drawable resources, and have them appear in the dependent apps?
That is not presently supported. Creating Android library projects that can distribute resources is on the tools roadmap and will hopefully come out in the not-too-distant future.
Upvotes: 2
Reputation: 15689
I dont think this is possible in the way you are trying to do that. Android "builds" recources inside its apks. Resources in jar files are (as far as I know) ignored.
You could However build it as an "android-library" where these xml layouts are included. If you don't want the whole code "easyly readable" you could put only this rescources and the classes that are using them inside the "android-library" while the rest inside your library stays inside the .jar file
Upvotes: 0