Thanks for looking.
I’m trying to put together a simple live wallpaper, and trying different methods for optimizing the speed of it. I’m bumbling around a bit, though, so forgive the simpleness of the question.
I’m trying to grab resourceIds by using (this code runs in the class CubeEngine(), which as you can guess I’m just working straight off the Cube demo)
private Resources res;
private int[] resID;
resID[0] = res.getIdentifier("n01","drawable",getPackageName());
Now I have 11 images I would like to load, and so I have 10 of that final line there. I know I could loop it, but I wanted to make it as simple as possible for the first go-round. The problem is that this returns a NullPointerException on execution. The image(s) in question are in res/drawable, and I have had no trouble accessing them before directly, as in
resBMP = BitmapFactory.decodeResources(res, R.drawable.n01);
for example. I’m guessing there is some simple thing that I am missing to get this working. I spend just about every day in MATLAB but haven’t worked with a language like java in many years, so even if it’s something as simple as syntactical error don’t overlook it and don’t hesistate to tell me of it!
Ernest’s comment solved the problem immediately.
Did you allocate resID (
resID = new int[10]) somewhere? If the NullPointerException is on that line, then either resID or res is null.