1. Download our Official Android App: Forums for Android!

Apps pass data from 1st activity to third activity in android

Discussion in 'Android Development' started by krishnaveni, Dec 22, 2012.

  1. krishnaveni

    krishnaveni Well-Known Member
    Thread Starter
    Rank:
    None
    Points:
    55
    Posts:
    158
    Joined:
    Dec 16, 2011

    Dec 16, 2011
    158
    0
    55
    chennai
    Hi


    This is my 1st activity code:

    Intent i = new Intent(getApplicationContext(), CustomerLogin.class);
    i.putExtra("GrandTotal", mGrandTotal);
    startActivity(i);


    This is my 2nd activity code:

    Intent in = getIntent();
    Bundle b = getIntent().getExtras();
    String total = b.getString("GrandTotal");
    TextView grandtotal = (TextView) findViewById(R.id.grand_total);
    grandtotal.setText("Welcome ," + total );

    Here the value is pass from 1st to 2nd activity successfully. Now i have to pass these value to third activity.how can i do.

    Now this is my 2nd activity:

    if(isUserValidated && isPasswordValidated)
    {

    Intent intent = new Intent(CustomerLogin.this,PayPalIntegrationActivity.class);
    intent.putExtra("GrandTotal", total);
    intent.putExtra("login",username.getText().toString());
    startActivity(intent);

    }




    This is my third activity:

    Bundle b = getIntent().getExtras();

    String total = b.getString("GrandTotal");
    TextView grandtotal = (TextView) findViewById(R.id.check);
    grandtotal.setText("Welcome ," + total );

    Now i have to run the app means am getting the total value on 2nd activity.but am not getting the total value in 3rd activity.please help me.whats am doing wrong here.



    This is my full source code:


    1st activity:#5564017 - Pastie


    2nd activity:#5564018 - Pastie


    3rd activity:#5564020 - Pastie


    Please check my code and give me solution for these.
     

    Advertisement

  2. myrecek

    myrecek Newbie
    Rank:
    None
    Points:
    16
    Posts:
    29
    Joined:
    May 10, 2012

    May 10, 2012
    29
    2
    16
    You store GrandTotal in the 2nd activity in local variable 'total' instead of the object field 'total'. Use

    [HIGH]total = b.getString("GrandTotal");[/HIGH]

    instead of

    [HIGH]String total = b.getString("GrandTotal");[/HIGH]

    And try some debugging next time ;)
     
  3. krishnaveni

    krishnaveni Well-Known Member
    Thread Starter
    Rank:
    None
    Points:
    55
    Posts:
    158
    Joined:
    Dec 16, 2011

    Dec 16, 2011
    158
    0
    55
    chennai
    I got the output.Thanks for your help.Thank You Very much.
     

Share This Page

Loading...