1

Umm, well im trying to pass an long that is extracted from a calendarview using getDate() method and set it to a long and pass it.. it works for one button i have mutiple buttons in the same interface and for the first button it works fine but for hte send one im having and issue as the data is not being passed :S

 //THis one passes the long without any issues
Create = (Button) findViewById(R.id.CreateApp);
        Create.setOnClickListener(new OnClickListener() {

            public void onClick(View arg0) {
                finish();

                 long date = Present.getDate();
                Intent Crea = new Intent(getApplicationContext(),CreateAppointment.class);
                Crea.putExtra("SelectedDate", date);
                startActivity(Crea);
            }

    });

//code when recieving in another class

Intent g = getIntent();
final long SDate = g.getLongExtra("SelectedDate", 0);


       //THE PROBLEM ONE :S
       Edit = (Button) findViewById(R.id.VEditApp);
       Edit.setOnClickListener(new OnClickListener() {

            public void onClick(View arViewg0) {
                finish();

                 long date = Present.getDate();
                Intent EDT = new Intent(getApplicationContext(),viewedit.class);
                EDT.putExtra("EDTDate", date);
                startActivity(EDT);
            }

    });

// WHat i use to recieve in the other class

Intent EditRecieve = new Intent();
        long Cur_Date = EditRecieve.getLongExtra("EDTDate", 2);

Can someone tell me why i am not getting the value and why the default value is kept on being passed?

2 Answers 2

0

In the example that doesn't work you wrote:

Intent EditRecieve = new Intent();
long Cur_Date = EditRecieve.getLongExtra("EDTDate", 2);

But in your first example which did work you wrote:

Intent g = getIntent();
final long SDate = g.getLongExtra("SelectedDate", 0);

So looks like a simple typo, replace "new Intent()" with "getIntent()" and you should be good.

1
  • Lol. Shoot. Thank alot men. :)
    – Shiva Bala
    Commented May 27, 2012 at 8:47
0

try this way finish your activty after you call new activity:::::

//THis one passes the long without any issues
Create = (Button) findViewById(R.id.CreateApp);
        Create.setOnClickListener(new OnClickListener() {

            public void onClick(View arg0) {


                 long date = Present.getDate();
                Intent Crea = new Intent(getApplicationContext(),CreateAppointment.class);
                Crea.putExtra("SelectedDate", date);
                startActivity(Crea);
                 finish();
            }

    });

/code when recieving in another class

Intent g = getIntent();
final long SDate = g.getLongExtra("SelectedDate", 0);


   //THE PROBLEM ONE :S
   Edit = (Button) findViewById(R.id.VEditApp);
   Edit.setOnClickListener(new OnClickListener() {

        public void onClick(View arViewg0) {



            Intent EDT = new Intent(getApplicationContext(),viewedit.class);
            EDT.putExtra("EDTDate", SDate );
            startActivity(EDT);
            finish();
        }

});

// WHat i use to recieve in the other class

 Intent EditRecieve = new Intent();
    long Cur_Date = EditRecieve.getLongExtra("EDTDate", 2);
3
  • Mr.Shankar my Create button sends and recieve, the problem is with the Edit button, please read carefully.
    – Shiva Bala
    Commented May 27, 2012 at 7:16
  • inal CalendarView Present = (CalendarView) findViewById(R.id.MainCalendar);
    – Shiva Bala
    Commented May 27, 2012 at 7:16
  • Lol. Mr.Shankar u certainly dont understand my question. :)
    – Shiva Bala
    Commented May 27, 2012 at 7:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.