I have a button

Button button = (Button)findViewById(R.id.button);
button.setBakgroundResource(R.drawable.icon);

If I want to check which background resource button has, is it possible to do so? how.

For example :

if (button.getResourceId()==R.drawable.icon)

do something with code...

UPDATE: THE CONDITION IS FALSE I WANT IT TO BE TRUE THE IMAGES DO NOT MATCH

vi.findViewById(R.id.button1).setOnClickListener(new OnClickListener(){

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            
 
            v.findViewById(R.id.button1).setBackgroundResource(R.drawable.boutton_off);
            
            Drawable aImg = (Drawable)v.findViewById(R.id.button1).getBackground();
            Drawable bImg = v.getResources().getDrawable(R.drawable.boutton_off);
            
            if(aImg==bImg){
                
                System.out.println("On");

            }else 
                System.out.println("off");

            
            
            //main.popMessage(position);
            
            
        }
        
    }); 
Edit
Report