Search code examples
javaandroidandroid-activityandroid-intent

Problem with passing information across Activities


I am trying to pass this:

Intent i=new Intent(ctx,SpendingsDetails.class);
extras.putString("SpendingAmount", "1");
extras.putString("SpendingDescription","2");
extras.putString("SpendingDate","3");
i.putExtras(extras);
startActivityForResult(i,1);

The activity that gets the information does the following information..

    spendingAmount=(TextView)findViewById(R.id.spending_Sum);
spendingDetails=(TextView)findViewById(R.id.spending_Details);

Bundle extras=getIntent().getExtras();
if(extras!=null)
{
    spendingAmount.setText(extras.getString("SpendingAmount"));
    spendingDetails.setText(extras.getString("SpendingDescription"));
}

I am getting an error that the application cant continue on the first activities screen.What am I doing wrong?


Solution

  • Use like this

    Intent i=new Intent(ctx,SpendingsDetails.class);
        i.putExtras("SpendingAmount", "1");
        i.putExtras("SpendingDescription","2");
        i.putExtras("SpendingDate","3");
        startActivityForResult(i,1);