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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T20:31:27+00:00 2026-05-28T20:31:27+00:00

When any music player playing a song, clicked on its notification it will show

  • 0

When any music player playing a song, clicked on its notification it will show us a current position of tracks, how?

I am creating an application, here I pressed on one button and its visibility set to GONE, and another button appears on its place like ON/OFF button. when I pressed ON, notification appears ON button GONE and OFF button VISIBLE, after that I am minimizing running application. Now when I clicked on notification, it have to show my last view of application where OFF is VISIBLE, ON is GONE instead of it, it launch the screen again where ON VISIBLE and OFF is GONE.

I used this code for that,

    String ns = Context.NOTIFICATION_SERVICE;
    mNm = (NotificationManager) getSystemService(ns);

    int icon = R.drawable.ic_launcher;        // icon from resources
    CharSequence tickerText = "my text";              // ticker-text
    long when = System.currentTimeMillis();         // notification time
    Context context = getApplicationContext();      // application Context
    CharSequence contentTitle = "my title";  // message title
    CharSequence contentText = "my message!";      // message text

    Intent notificationIntent = new Intent(Intent.ACTION_MAIN);

    notificationIntent.setClass(getApplicationContext(), DontTouchMyDroidActivity.class);
    contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT | Notification.FLAG_AUTO_CANCEL);
            // the next two lines initialize the Notification, using the configurations above
    notification = new Notification(icon, tickerText, when);
    notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
  • 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-28T20:31:28+00:00Added an answer on May 28, 2026 at 8:31 pm

    You are very close. You need can pass data in your Intent. There are 2 parts to this:

    1)

    When you create your Intent, you add extra data to that intent. For example, you could add a String called ON_VISIBLE, and set it to "true". Here is some code to add extras to the intent that you created:

        Intent notificationIntent = new Intent(this, DontTouchMyDroidActivity.class);
        notificationIntent.putExtra("ON_VISIBLE", "true");
        notificationIntent.putExtra("SOME_OTHER_DATA", "look at help for putExtra()");
    

    This adds extra information as part of a Bundle to the Intent (look for help on Bundle & Intent.putExtras())

    2)

    When you receive your Intent, you need to extract that information from it. Here is some code to take the Bundle out of your Intent. You can then use the values to determine if you want to show or hide the buttons.

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
    
        // retrieve bundle extras passed into this intent
        String onButtonVisible = "false";
        Bundle extras = getIntent().getExtras();
        if (extras != null)
        {
            onButtonVisible = extras.getString("ON_VISIBLE");
        }
    
        Boolean makeVisible = Boolean.valueOf(onButtonVisible);
        if (makeVisible)
        {
            // make your ON button visible
        }
    }
    

    This is the method that will get called if your Activity is being created.

    If your Activity is still alive in the background, then you need to do something similar in the method Activity.onNewIntent(Intent intent)

    /** Called if activity is being brought in from background by a new intent. */
    @Override
    protected void onNewIntent(Intent intent)
    {
        Bundle extras = intent().getExtras();
        if (extras != null)
        {
            onButtonVisible = extras.getString("ON_VISIBLE");
        }
    
        // do something similar here
    }
    

    So the short answer is that you add "extras" to your Intent when you create it. These "extras" are added to a Bundle which you can then query when your Activity is launched. And also, to know that there are 2 methods you need to know about where you can query the extras.

    A bit of Googling on Intent, extras, Bundle, should fill in any info that I have left out.

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

Sidebar

Related Questions

I'm, creating a player app. I've implemented 'remoteControlReceivedWithEvent:' method and could change playing state
I'm designing a music player app for Android that will feature pop-up controls. I'm
My application uses polling to update the status of a music player. I'm using
I'm planning of creating a Last.FM scrobbler plugin for a music player in Windows.
This question is very specific, on how to make a music playing application like
I am making a site which will have music playing on the site using
Is there any way to programatically open the Android Music Player? I'm sure there
I have the music player application in which I have 90 songs total. I
Can any one suggest me how to play the music using MPMusicPlayerController in my
Any personal experience in overcoming web application performance hurdles? Any recommended strategies for improving

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.