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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T11:23:27+00:00 2026-06-15T11:23:27+00:00

I have several activities which use several audio features. For that, I have a

  • 0

I have several activities which use several audio features. For that, I have a MediaPlayer in a singleton java class, so the activities interact with that class and just exist on the media player.

One of the features is to stop automatically the media player after X minutes. So I created a timer in the singleton class and stops perfectly the radio streaming. the problem is that there is no feedback or callback to the running activity. There is a play/stop button wich has to change the image and I do not know how can I capture that onStop event or whatever….or can be called from a single java class the current activity class running, so I could call a function of the activity in order to change the image?

  • 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-15T11:23:28+00:00Added an answer on June 15, 2026 at 11:23 am

    You probably want to use a broadcast receiver for this.

    From your singlton class which does the stopping, when your timer stops the music, call this method:

    public void broadcastMusicPaused(View v){
        Intent broadcast = new Intent();
        broadcast.setAction("MUSIC_STOPPED");
        sendBroadcast(broadcast);
    }
    

    Then, from your controlling activity, set up your receiver like this:

    private BroadcastReceiver receiver = new BroadcastReceiver() {
    
        @Override
        public void onReceive(Context context, Intent intent) {
            // TODO Auto-generated method stub
            Toast.makeText(getApplicationContext(), "Music Paused", Toast.LENGTH_SHORT).show();
            displayMusicStopped();       //switches images
        }
    };
    
    @Override
    protected void onResume() {
        IntentFilter filter = new IntentFilter();
        filter.addAction("MUSIC_STOPPED");
        registerReceiver(receiver, filter);
    
        super.onResume();
    }
    
    @Override
    protected void onPause() {
        unregisterReceiver(receiver);
        super.onPause();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a one main Workflow which calls several activities asynchronously. Some of the
In my application I have several activities, the main screen has 4 buttons that
In my game application I have several different activities that all can be accessed
I have an app that contains several activities...so lets say user is navigating activity
I have some data/helper classes defined which I use in several projects. These data
I have an app with several 'normal' activities which can run on either landscape
I have two Activities, both have an inner class SurfaceView, which has an inner
I have a service which provides current location of the device. Several activities in
I have a game which has several activities before the game starts. For example,
I have an existing project which is an application that runs several flows, calling

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.