If I get the image name as a variable like following:
var imageName = SERVICE.getImg();
Then, how can I get the resource with R.drawa
R.drawa
Try this:
int id = getResources().getIdentifier(imageName, "drawable", getPackageName());