play music when a specific image is appeared android
<p>I have this code:<br>
        openHandlera = new ViDBOpenHandler(this);     </p>

<pre><code>         Runnable ru = new Runnable(){      
             public void run(){     

                 int imageArrr[] = new int[2];      
                 imageArrr[0] = R.drawable.crossone;      
                 imageArrr[1] = R.drawable.blackone;      

                 int n = (int)( Math.random()*2);      

                 theIm.setImageResource(image[n]);     
                 if(n == 0) {     
                     Log.v("Result", "n is 0 now");     
                     startTimea = System.currentTimeMillis();     
                     final SoundGenerator task=new SoundGenerator();     
                     task.keepPlaying(true);     
                     task.setLoudness(audioLoudnessa);     
                     task.execute(audioFrequencya);     

                     new Handler().postDelayed(new Runnable() {     
                          public void run()           {                           
                            task.keepPlaying(false);      
                        }     
                    }, 1000);      
                }       
                 new Handler().postDelayed(new Runnable() {     
                     public void run() {                     

                         finish();      
                     }      
                }, 30000);       

                  Log.v("test", "is"+ startTimea);      
                  theIm.postDelayed(this, 3000); //set to go off again in 3 seconds.      
            }      
        };       
        theIm.postDelayed(ru,1500);         
</code></pre>

<p>In this code I want to say that if my image is equal to imageArrr[1], then play music for one second and set current time to start time. The problem is that I used if(n==0). but it seems that it doesnt recognize the this way of implementing. Because it doesnt go to if and I can not hear sound and even it doesnt print anything. Can anybody guide me that what should I do?</p>
