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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T07:50:35+00:00 2026-06-05T07:50:35+00:00

I have a animation xml file: <?xml version=1.0 encoding=utf-8?> <animation-list xmlns:android=http://schemas.android.com/apk/res/android android:id=@+id/anim android:oneshot=true >

  • 0

I have a animation xml file:

<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/anim"
    android:oneshot="true" >

    <item
        android:drawable="@drawable/pik1"
        android:duration="150"/>
    <item
        android:drawable="@drawable/pik2"
        android:duration="150"/>

</animation-list>

What i want to do is start and keep running the animation while mediaplayer is playing and stop the animation when mediaplaye is finished playing.

For Example: The mediaplayer is playing a sound which is 5 seconds long, i want to play the animation for 5 seconds an then stop is.

This is the jave code i have in my main activity:

piks.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                if (play != null) {
                    play.reset();
                    play.release();
                }
                play = MediaPlayer.create(pikselActivity.this,
                        R.raw.pisound);
                play.start();
                frame.start();


            }
        });

frame.start() starts the animation, but when the sound is finished, the animation keeps running. How do i make the animation stop when the sound is finished?

  • 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-05T07:50:37+00:00Added an answer on June 5, 2026 at 7:50 am

    put an onCompletionListener() on your media player. Inside the callback for media complete add

    frame.clearAnimation();
    

    like this:

    if (play != null) {
        play.reset();
        play.release();
    }
    play = MediaPlayer.create(pikselActivity.this,R.raw.pisound);
    
    
    play.setOnCompletionListener(new OnCompletionListener() {
        public void onCompletion (MediaPlayer mp){
            frame.clearAnimation();
        }
    });
    play.start();
    frame.start();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an animation specified in xml like this: <?xml version=1.0 encoding=utf-8?> <set xmlns:android=http://schemas.android.com/apk/res/android>
i can use an XML file like below <set xmlns:android=http://schemas.android.com/apk/res/android android:interpolator=@android:anim/decelerate_interpolator> <translate android:fromXDelta=100% android:toXDelta=0%
i have made the following animation xml file in my android project: <?xml version=1.0
I do have a xml file located at : http://api.wunderground.com/api/adaebe40743a9ca6/geolookup/conditions/forecast/q/India/Pilani.xml Now i want to
I have created animation.xml file in which i have added my stuff of frame
I'm trying to use Android's animation framework to have my ImageView move in a
I have an ImageView in my xml file, i want to rotate the image
I want have animation on hovering a which shall slide from top and on
I have some animation that was created in the main timeline in an FLA
I have an animation written in JavaScript. I want to render it to a

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.