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

  • Home
  • SEARCH
  • 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 6018345
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:15:43+00:00 2026-05-23T03:15:43+00:00

I want to send a broadcast (or is it an intent?) from my app

  • 0

I want to send a broadcast (or is it an intent?) from my app that will go to the next track of a music player if something is playing, or play/pause, etc. Here is the code that I have so far:

    final Intent i = new Intent(Intent.ACTION_MEDIA_BUTTON);
    i.putExtra(Intent.EXTRA_KEY_EVENT, KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE);
    context.sendBroadcast(i); 

However as far as I can tell from my testing this code snippet doesn’t quite do anything. Btw I put this code into a function and call it from a background service, in case that’s relevant.

So how can I get this functionality working? If it’s not possible for some reason I’m open to suggestions for work-arounds and/or alternate solutions.

Much appreciated, thanks.

  • 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-23T03:15:44+00:00Added an answer on May 23, 2026 at 3:15 am

    You’re using EXTRA_KEY_EVENT improperly. See Intent#EXTRA_KEY_EVENT. You need to instantiate a new KeyEvent object with the KEYCODE_MEDIA_PLAY_PAUSE keycode. Just passing the keycode in the intent is passing it as an Integer, not as a KeyEvent.

    This thread shows an example of creating the KeyEvent object.

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

Sidebar

Related Questions

I want to be able to send files from an iPhone app to a
I want to use sendBroadcast to broadcast an intent that can only be received
I want to send a broadcast message with intent within extra data of my
I want to send a broadcast from my widget with this code: for (int
Want to send the text from my current vb application to the Active Window
I want to send broadcast message to all peers in my local network. Message
I want to simply call one function that is defined in BroadClass Activity from
Same as the title. I want to use sendBroadcast(intent) to start broadcast; and then
I want to send an intent to my service everytime the state of Wifi
A service send this broadcast: Intent _broadcast = new Intent(); _broadcast.setAction(it.lorenzoff.uselesssoftware); sendBroadcast(_broadcast); Why my

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.