Reputation: 678
There are several java files combined into a package. Is it possible to add an icon to this package and access it from this package?
assumption:
package com.foobar;
import com.foobar.Resources;
...
.setSmallIcon(Resources.drawable.icon)
I know how to put images in the main application package. These images are accessed through the R package, which must be imported using the name of the main package. import main.package.name.R
. But I need to avoid using the main package name and have the ability to access the image.
Upvotes: 0
Views: 47
Reputation: 4835
Yes, use something like this to access it.
.setSmallIcon(getResources().getDrawable(com.foobar.drawable.icon));
Your other "package" must be an android library module, just include the drawables in the usual res/drawable folder.
Ensure you include your other module within your main module by adding it to your gradle.
implementation project(':foobar')
Also ensure you include both your main and foobar module in your settings.gradle
include ':main', ':foobar'
Upvotes: 1