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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T21:27:43+00:00 2026-05-16T21:27:43+00:00

I am trying to start an activity from the notification bar but it needs

  • 0

I am trying to start an activity from the notification bar but it needs to get an int. From activity to activity I would just put an int into the intent but I can’t seem to figure out where to add the extra for the notification bar? Is this possible? If not is there a better way to do it?

public void notifyMe() {
    int icon = android.R.drawable.presence_away;
    CharSequence tickerText = "New Task Availible";
    long when = System.currentTimeMillis();

    Notification notification = new Notification(icon, tickerText, when);

    Context context = getApplicationContext();
    CharSequence contentTitle = "PRISM Task";
    CharSequence contentText = "New Task Availible";
    Intent notificationIntent = new Intent(this, TextAnswerActivity.class);
    PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
    notificationIntent.putExtra("taskId", 20);  //unable to retrieve 20 later

    notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);

    final int HELLO_ID = 1;

    mNotificationManager.notify(HELLO_ID, notification);
}

How I am retrieving:

Intent myIntent = getIntent();
System.out.println("#######TaskID from Intent ===== " + myIntent.getIntExtra("taskId", -1));
  • 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-16T21:27:43+00:00Added an answer on May 16, 2026 at 9:27 pm

    You have to call notificationIntent.putExtras(…) before creating PendingIntent that takes notificationIntent as a parameter. Try this code out:

            Intent notificationIntent = new Intent(this, TextAnswerActivity.class);
            notificationIntent.putExtra("taskId", 20);
    
            PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
    
            Notification notification = new Notification(icon, tickerText, when);
            notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent); 
    

    And to receive the data:

        Bundle b = getIntent().getExtras();
        if (b != null) {
            int taskId = b.getInt("taskId");
            System.out.println("############# taskID: " + taskId);
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new on Android, and I'm trying to start an Activity from a MenuItem
Hi I have a listview and, I am trying to start an activity from
I am trying to start a service from the command line using net start
I'm trying to start using LINQ and specifically LINQ to SQL but I'm having
Why do I get following error when trying to start a ruby on rails
I am trying to start my VPN connection (using VPNC) from PHP. I have
I am getting this exception when trying to start an activity (TestLocationActivity) that is
I'm trying to start a service as a user and things work fine, until
I'm trying to start a service that has a argument that specifies a port
I am actually trying to start a process for winzip and zip a folder.

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.