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 9188823
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:06:20+00:00 2026-06-17T20:06:20+00:00

In my activity i am playing animations.. When i am starting the activity for

  • 0

In my activity i am playing animations.. When i am starting the activity for first time,all the animations are playing with the given duration. But it is speed up when i am repeating each and every animation for more time.. This is my activity…. And In my code i haven’t provide all object and variable declaration to reduce the code…

public class Exercise extends Activity {
/** Called when the activity is first created. */

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.exercise);

    exercise_Layout=(RelativeLayout)findViewById(R.id.exerciselayout);

    exercise_Layout.setBackgroundResource(R.drawable.exercise_bg);

    if(getIntent().getStringExtra("TIPS").equals("Fun"))
    {
     count=0;
     System.out.println("This is Fun");
    }
    else if(getIntent().getStringExtra("TIPS").equals("Tips"))
    {
     count=1;

    }
gym.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            // TODO Auto-generated method stub
                            exercise_Layout.setBackgroundResource(R.drawable.exercise_bg);
            gym_View.setBackgroundResource(R.anim.gymanim);
            gym_Animation=(AnimationDrawable)gym_View.getBackground();
            gym_Animation.start();
            //playing sounds
            mp.reset();
            mp=MediaPlayer.create(getApplicationContext(),R.raw.gym);   
            try {
                mp.prepare();
            } catch (IllegalStateException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            mp.start();
            mp.setLooping(true);    

        }
    });

    run.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            // TODO Auto-generated method stub
                            exercise_Layout.setBackgroundResource(R.drawable.exercise_bg);
            run_View.setBackgroundResource(R.anim.runanim);
            run_Animation=(AnimationDrawable)run_View.getBackground();
            run_Animation.start();
            //playing sounds
            mp.reset();
            mp=MediaPlayer.create(getApplicationContext(),R.raw.thread_music);  
            try {
                mp.prepare();
            } catch (IllegalStateException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            mp.start();
            mp.setLooping(true);    

        }
    });

    jogg.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            // TODO Auto-generated method stub

            jogg_View.setBackgroundResource(R.anim.jogroadanim);
            jogg_Animation=(AnimationDrawable)jogg_View.getBackground();
            jogg_Animation.start();
            //playing sounds
            mp.reset();
            mp=MediaPlayer.create(getApplicationContext(),R.raw.jogging);   
            try {
                mp.prepare();
            } catch (IllegalStateException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            mp.start();
            mp.setLooping(true);    

        }
    });

    swim.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            // TODO Auto-generated method stub

            exercise_Layout.setBackgroundResource(R.drawable.swimingpool);
            swim_View.setVisibility(View.VISIBLE);

            swim_View.setBackgroundResource(R.anim.swimanim);
            swim_Animation=(AnimationDrawable)swim_View.getBackground();
            swim_Animation.start();
            //playing sounds
            mp.reset();
            mp=MediaPlayer.create(getApplicationContext(),R.raw.swimming);  
            try {
                mp.prepare();
            } catch (IllegalStateException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            mp.start();
            mp.setLooping(true);    

        }
    });
}
  • 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-17T20:06:21+00:00Added an answer on June 17, 2026 at 8:06 pm

    I´m not sure, but if you use CountDownTimers and you press multiple times on it, you start them twice or more times. Maybe its the same issue to your animations. I see there swim_Animation.start(); for example.. try swim_Animation.stop(); before reactivating it. I hope I didn’t misunderstand you explanation..

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

An Activity occurs at a location on a specific date, but each activity may
I started playing with Postsharp but cannot get past the first step. Someone else
Activity GameActivity : The page that's opened when the application is first opened. Activity
My application has one activity which starts two services but does not bind them.
I'm just playing around with some code. I create an Activity and simply do
So I'm playing with the ViewPager and Fragments, but I'm stuck with a problem:
I have an android app that has mutliple activities The first main activity starts
I recently wrote a Java playing card game and have all the game logic
I have two activity: MediaPlayer_Activity (display the control like play,pause,stop,next....) MediaPlayerPlayList_Acitivty (to display all
I'm playing with an algorithm to 'solve' activity networks - it's for a course

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.