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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T23:17:22+00:00 2026-05-24T23:17:22+00:00

I wanted to create a broadcastreceiver which listens for android.intent.action.MEDIA_BUTTON, and get the extra_key_event

  • 0

I wanted to create a broadcastreceiver which listens for android.intent.action.MEDIA_BUTTON, and get the extra_key_event from that and act accordingly. Somehow the onreceive action is not performed.

In my Manifest:

receiver android:name="MediaButtonReceiver"
intent-filter
 action android:name="android.intent.action.MEDIA_BUTTON" 
intent-filter

receiver

In my broadcastreceiver:

public class MVCS extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
    if (Intent.ACTION_MEDIA_BUTTON.equals(intent.getAction())) {
        /* handle media button intent here by reading contents */
        /* of EXTRA_KEY_EVENT to know which key was pressed    */

        KeyEvent ke = (KeyEvent)intent.getExtras().get(Intent.EXTRA_KEY_EVENT); 
        if (ke .getKeyCode() == KeyEvent.KEYCODE_VOLUME_DOWN) {
            Toast.makeText(context, "BUTTON PRESSED!", Toast.LENGTH_SHORT).show();  
        }
    }
}

However, nothing is displayed when i press the volume down key.

Any help would be much appreciated!

  • 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-24T23:17:24+00:00Added an answer on May 24, 2026 at 11:17 pm

    You need to register your broadcast receiver in your Activity, with method registerReceiver().
    As your code is not complete here, I can’t tell you exactly how, but bear in mind that after instantiate your MVCS class, you should register like:

    MyActivity.registerReceiver( myBroadcastReceiver, MediaButtonReceiver);

    Better way of doing this is to register your receiver in OnStart() of your activity and unregister it in OnStop().

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

Sidebar

Related Questions

I wanted to create a page with a simple button which runs away from
i wanted to create a forloop which will create a table from the data
I wanted to create a method in Android that could communicate with a WCF
I wanted to create a very simple method that switches between views in a
I wanted to create one js file which includes every js files to attach
I wanted to create a function which would return the path of the current
I wanted to create a box that you could click on and be forwarded
I wanted to create a new WordPress page that is actually a link to
I wanted to create a simple program which would generate random numbers between 0
I wanted to create a WCF that employs a singleton pattern but the service

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.