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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T05:57:33+00:00 2026-05-24T05:57:33+00:00

I realize the music application may or may not be the same depending on

  • 0

I realize the music application may or may not be the same depending on the device, but I’m writing this application for my own device.

Am I correct in thinking I will need to create a service with my widget, then somehow bind this service to com.android.music.MediaPlaybackService?

I’m not finding much useful documentation on this, but looking in the market, there are numerous widgets that do this same thing. I’ve seen a few StackOverflow answers saying this is just not possible, yet at the same time, I’ve installed several widgets that do precisely this.

Has anyone done something similar that can point me in the right direction?

  • 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-05-24T05:57:34+00:00Added an answer on May 24, 2026 at 5:57 am

    As of at least Android 2.2.2 this method does work.

    I created a service for my widget. The onCreate of this service binds to com.android.music.IMediaPlaybackService.

    The onStart of this service checks for a “command” flag and accordingly runs the bound service’s appropriate method through a private ServiceConnection, then the key was clearing the connection after every command, for example:

    private ServiceConnection mConnection = new ServiceConnection(){
            public void onServiceConnected(ComponentName className,
                    IBinder service) {
                mService = IMediaPlaybackService.Stub.asInterface(service);
    
                //Toast.makeText(getApplicationContext(), "!!!", Toast.LENGTH_SHORT).show();
                try {
                    if (mService.isPlaying()) {
                        mService.pause();
                    } else {
                        mService.play();
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                    throw new RuntimeException(e);
                }
                unbindService(mConnection);
            }
    
            @Override
            public void onServiceDisconnected(ComponentName name) {
                // TODO Auto-generated method stub
                mService = null;
            }
    
        };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I realize this may be a simple problem, but I am new to ASP.net
I realize this is not necessarily the smartest way to do this, but now
I realize this might not be the best setup, but humor me, is it
I realize that this is not possible since Android doesnt have a JVM but
I realize this is fairly abstract, but I'd like to do something not unlike
I realize this would violate convention, but I'm curious to know if you can
I realize that this would be COMPLETELY bad practice in normal situations, but this
I realize this might be a long shot, but does anyone have an example
I realize this is a contrived example, but I want a compile check to
I realize there are several topics about this issue, but none provides a working

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.