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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:12:49+00:00 2026-06-13T13:12:49+00:00

I have 3 activities, Act 1, Act 2, and Act 3. In my Activity

  • 0

I have 3 activities, Act 1, Act 2, and Act 3. In my Activity 1, the user sets the title, description of his desired event, the date and the time it should notify the user. When the user clicks on the button DONE, the notification ID is passed to my Activity 2, to display the notification. When the time comes for it to notify, it then now displays the Activity which shows the details of the event the user created in the Activity 1. My problem is how to view the data that have been passed to Activity 3?

This is the code I’m working on:

Activity 1:

//---Button view---
    Button btnOpen = (Button) findViewById(R.id.button1);
    btnOpen.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {                
            timePicker = ( TimePicker ) findViewById( R.id.timePicker1 );
            datePicker = ( DatePicker ) findViewById( R.id.datePicker1 );      
            title = (EditText) findViewById (R.id.editText1);
            description = (EditText) findViewById (R.id.editText2);

            //---use the AlarmManager to trigger an alarm---
            AlarmManager alarmManager = ( AlarmManager ) getSystemService( ALARM_SERVICE );                 

            //---get current date and time---
            Calendar calendar = Calendar.getInstance();       

            //---sets the time for the alarm to trigger---
            calendar.set( Calendar.YEAR, datePicker.getYear() );
            calendar.set( Calendar.MONTH, datePicker.getMonth() );
            calendar.set( Calendar.DAY_OF_MONTH, datePicker.getDayOfMonth() );                 
            calendar.set( Calendar.HOUR_OF_DAY, timePicker.getCurrentHour() );
            calendar.set( Calendar.MINUTE, timePicker.getCurrentMinute() );
            calendar.set( Calendar.SECOND, 0 );

            //---PendingIntent to launch activity when the alarm triggers---                    
            Intent i = new Intent( NotifyActivity.this, DisplayNotification.class );

            //---assign an ID of 1---
            i.putExtra( "NotifID", 1 ); 

            Intent d = new Intent( NotifyActivity.this, AlarmDetails.class );
            d.putExtra( "Title", title.getText().toString() );
            d.putExtra( "Description", description.getText().toString() );

            PendingIntent displayIntent = PendingIntent.getActivity(
                getBaseContext(), 0, i, 0 );               

            //---sets the alarm to trigger---
            alarmManager.set( AlarmManager.RTC_WAKEUP, 
                calendar.getTimeInMillis(), displayIntent );
            finish();
        }
    }); 

Activity 2:

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

//---PendingIntent to launch activity if the user selects 
// the notification---
Intent i = new Intent( DisplayNotification.this, AlarmDetails.class );
i.putExtra( "NotifID", notifID );  

PendingIntent detailsIntent = 
    PendingIntent.getActivity(this, 0, i, 0);

NotificationManager nm = (NotificationManager)
    getSystemService(NOTIFICATION_SERVICE);
Notification notif = new Notification(
    R.drawable.ic_launcher, 
    "iHealthFirst: Notification!",
    System.currentTimeMillis());

CharSequence from = "AlarmManager - New Notification";
CharSequence message = "This is your alert, click to view";        
notif.setLatestEventInfo(this, from, message, detailsIntent);

//---100ms delay, vibrate for 250ms, pause for 100 ms and
// then vibrate for 500ms---
notif.vibrate = new long[] { 100, 250, 100, 500};        
nm.notify(notifID, notif);
//---destroy the activity---
finish();
}

and Activity 3:

    @Override
public void onCreate(Bundle savedInstanceState) 
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.alarmdetails);  

    //---look up the notification manager service---
    NotificationManager nm = ( NotificationManager ) 
        getSystemService( NOTIFICATION_SERVICE );

    //---cancel the notification---
    nm.cancel( getIntent().getExtras().getInt( "NotifID" ) ); 

    Bundle extras = getIntent().getExtras(); 
    if(extras !=null)
    {
    String strTitle = extras.getString( "Title" );
    String strDescription = extras.getString( "Description" );
    title.setText( strTitle );
    description.setText( strDescription );
    }
}

In the Activity 3, I put this

        **Bundle extras = getIntent().getExtras(); 
    if(extras !=null)
    {
    String strTitle = extras.getString( "Title" );
    String strDescription = extras.getString( "Description" );
    title.setText( strTitle );
    description.setText( strDescription );
    }**

But I can’t seem to display the details. Any help is truly 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-06-13T13:12:50+00:00Added an answer on June 13, 2026 at 1:12 pm

    Maybe not the best solution, but you can use the DefaultSharedPreferences to save the values.

    Save the values in Activity 3:

    //Determine the String values
    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
    Int numberOfEvents = preferences.getInt("numberofevents", 0);
    numberOfEvents++;
    preferences.putString("title" + numberOfEvents, titleVariable);
    preferences.putString("description" + numberOfEvents, descriptionVariable);
    preferences.putInt("numberofevents", numberOfEvents);
    preferences.commit();
    

    Do something with the Strings from the events in Activity 1:

    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
    int numberOfEvents = preferences.getInt("numberofevents", 0);
    for(int i = 0; i < numberOfEvents; i++) {
        String titleVariable = preferences.getString("title" + i, "");
        String descriptionVariable = preferences.getString("description" + i, "");
        if(!titleVariable.equals("") && !descriptionVariable.equals("")) {
            //use the String variables for you notification
        }
    }
    

    When deleting an event in Activity 3:

    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
    //get id number of event to delete and store it in variable variableNameOfEventNumber
    preferences.putString("title" + variableNameOfEventNumber, "");
    preferences.putString("description" + variableNameOfEventNumber, "");
    preferences.commit();
    

    I hope this helps.

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

Sidebar

Related Questions

I have a table of user activity. I have the HWA, the date of
I have four activities namely, Demo_tabActivity.java [main activity] Tabhost.java The below two activities are
I have four activities namely, Demo_tabActivity.java [main activity] Tabhost.java The below two activities are
I have two activities. In first I come to the second activity from first
I have 2 activities. The first activity is an activity that parses JSON data
In our app, we have Activities A,B,C,D, and E. The user usually goes from
I have two activities; Home is my first activity and Settings is my second
I have two activities in my Android project: Google Map Activity List Activity I'm
I have three activities 1 is the main activity 2 is some other activity
I have two activities, activity1 is starting activity2. in activity 2 I registered an

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.