How to access image resource from res/drawable folder in native code?
I have been looking for some method in order to access resources like images stored in res/drawable folder. Actually I am s开发者_StackOverflow中文版earching for some procedure similar to our Java code i.e. accessing resources saved in res/drawable from the R.drawable class. Is there any thing similar technique provided in native code also? If not then there should be some alternative to access these resources, kindly tell me what is it. Looking for an early reply. Thanks in advance. With Regards, Atul Prakash Singh
I think you should pass a FileDescriptor
of the resource you are trying to access to the native procedure.
Create a Uri by passing a string to it. Like this:
String s = "android.resource://[your_package]/R.drawavle.img";
Uri u = Uri.parse(s);
getResources().getIdentifier(name,"drawable", getPackageName())
精彩评论