Canvas - null pointer exception

view full story

http://stackoverflow.com – Sometimes, I am getting null pointer exception in the line. Please let me know how to correct this. At the time of error, I have checked the possibility for the null value in variable backgoundImage. The variable backgoundImage is not null. canvas.drawBitmap(backgoundImage, 0, 0 , null); Code: @Override public void run() { // TODO Auto-generated method stub ourHolder = getHolder(); while (isRunning) { if (!ourHolder.getSurface().isValid()){ continue; } canvas = ourHolder.lockCanvas(); (HowTos)