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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T11:06:41+00:00 2026-06-05T11:06:41+00:00

I’m trying to get content from a textview in another activity to show up

  • 0

I’m trying to get content from a textview in another activity to show up in a notification bar message. It works, but not correctly. The string from the textview does show up in the notification, and I’m doing that by bundling the info from the other activities’ textview and then have the notification manager grab the bundle. The problem arises when the other activity is launched, it fires off the notification because the last chunk of code in the activity does the bundling and sending, which causes the notification to fire, ignoring the set firing time. So my question is What’s the best and easiest way to have a notification grab a string from another activity? Here’s the activity, which is the problem. It fires the notification on it’s own:

    import java.io.IOException;

import android.app.Activity;
import android.app.NotificationManager;
import android.content.Intent;
import android.database.SQLException;
import android.os.Bundle;
import android.widget.TextView;

public class DBTest2 extends Activity {

String scrNote;
TextView showBV;
NotificationManager nm;
DBAdapter dba;

@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.dbtest_2);
    showBV = (TextView) findViewById(R.id.getBK_TV);

    nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    //---cancel the notification---
    try{
    nm.cancel(getIntent().getExtras().getInt("uID"));
    } catch (Exception e) {
        System.out.println("Error when cancelling: "+e.toString());
    }
    //---END cancel the notification---



    //---- SHOW IN NOTIFICATION------

    scrNote = showBV.getText().toString();
    Bundle moveScrNote = new Bundle();
    moveScrNote.putString("mSN", scrNote);
    Intent toNoteBody = new Intent(DBTest2.this, DisplayNotifications.class);
    toNoteBody.putExtras(moveScrNote);
    startActivity(toNoteBody);


    //---- END   SHOW IN NOTIFICATION------


}


}

and here is the notification manager:

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    //---get the notification ID for the notification; 
    // passed in by the MainActivity---
    int uID = getIntent().getExtras().getInt("uniqueID");

    //---PendingIntent to launch activity
    Intent noteI = new Intent("com.vee.search01.DBTEST2");
    noteI.putExtra("uniqueID", uID);

    PendingIntent herroIntent = 
        PendingIntent.getActivity(this, 0, noteI, 0);

    nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    long fireTime = System.currentTimeMillis();
    String noteTitle = "Notification Title";

    Bundle getNoteBody = getIntent().getExtras();
    String gotNoteBody = getNoteBody.getString("mSN");
    String noteBody = gotNoteBody;

    Notification note = new Notification(R.drawable.noteicon, noteTitle, fireTime);
    note.setLatestEventInfo(this, noteTitle, noteBody, herroIntent);
    note.defaults |= Notification.DEFAULT_SOUND;
    note.defaults |= Notification.FLAG_SHOW_LIGHTS;
    nm.notify(uID, note);
    finish();
}

}
  • 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-06-05T11:06:43+00:00Added an answer on June 5, 2026 at 11:06 am

    The best way to transfer content between activities is to send it via extras in an Intent.

    If you’re issuing a notification from Activity A, and you want to handle it in Activity B,
    then create the notification in A and insert a PendingIntent containing an Intent to start
    B. When the notification displays and the user clicks it, B should be fired.

    If you want to send the notification text from B to A, use a separate Intent.

    If you’re trying to send the text of the notification Intent to B as well as display the
    notification, put the text in the Intent’s extras.

    Also, if you’re on a recent version of the platform, go read the reference docs for Notification. It’s been deprecated in favor of creating notifications through Notification.Builder. One advantage is that you can set the notification to auto-cancel, so you don’t have to cancel it in code.

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

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
Basically, what I'm trying to create is a page of div tags, each has
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this

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.