Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8302989
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T17:25:03+00:00 2026-06-08T17:25:03+00:00

I have this code: openHandlera = new ViDBOpenHandler(this); Runnable ru = new Runnable(){ public

  • 0

I have this code:
openHandlera = new ViDBOpenHandler(this);

         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);         

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T17:25:04+00:00Added an answer on June 8, 2026 at 5:25 pm
    int n = (int)( Math.random()*2);      
    

    you are generating value of n randomly and you are not getting zero any time

    so your condition if(n == 0) never becomes true. and you are not getting proper output.

    EDIT : You can use like this

    if(n>2>
       int image =imageArrr[0];
    else
       int image =imageArrr[1];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code : void Main() { System.Timers.Timer t = new System.Timers.Timer (1000);
I have this code: ImageButton call = new ImageButton(context); call.setId(9001+result.index); call.setBackgroundResource(R.drawable.small_call); LinearLayout.LayoutParams call_params =
I have this code: public void onPlayerInteract(PlayerInteractEvent event) { final Action action = event.getAction();
i have this code which doesnt work: void CAnalyzerIF::SetData(int i_iIters, const CParameterSet* i_CParameterSet) {
have this code: void set(list<Person*>* listP){ Person timmy = Person(10); listP->push_back(&timmy); } int main()
I have this code: private void FillCombobox() { using (InventoryEntities c = new InventoryEntities(Properties.Settings.Default.Connection))
I have this code for changing the image of a button: - (void)mouseEntered:(NSEvent *)event
I have this code: con.Open(); cmd = new MySqlCommand(String.Format(SELECT concat(name,'|',lastname) FROM {0} WHERE ID=
I have this code: class LFSeq: # lazy infinite sequence with new elements from
I have this code: foreach(int i in Directions) { if (IsDowner(i)) { while (IsDowner(i))

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.