I am using intent to call activity here and I need to send to long variable to the other activity.
Porjct.java
Intent i = new Intent(ProjectList.this,RoleList.class);
Bundle c = new Bundle();
c.putLong("PID", projectID );
c.putLong("CTSID", castingTimeSlotID);
i.putExtras(c);
startActivityForResult(i,0);
finish();
RoleList.java
public void onActivityResult(int requestCode, int resultCode, Intent data) {
Bundle c = new Bundle();
c = data.getExtras();
projectID = b.getLong("PID");
castingTimeSlotID = b.getLong("CTSID");}
This is not working.
Edit:
The
onActivityResult()should be in ProjectList.java – it will be called when your child Activity returns.Your child Activity in RoleList.java should retrieve the data sent by the parent from the Bundle passed via
onCreate()If this is a little confusing; I suggest you read this first: http://www.remwebdevelopment.com/dev/a33/Passing-Bundles-Around-Activities.html – the example in there is very complete and they explain it better than I do. Notice how they pass data with key “mykey” from the parent Activity to the child; this is what you want to do.
Previous useless answer of mine follows
I think you don’t need to retrieve the extras via a Bundle. Try this: