I want to pass an integer value from activity A to B, to C. A contains the calories, B specifies how you exercise and C calculates your final calories intake the default way; but data is not transferred to activity C.
Intent i = new Intent(getApplicationContext(), ActivityC.class);
Bundle extras = new Bundle();
i.putExtras(extras);
extras.putDouble("clllo", calories);
startActivity(new Intent("com.ti7a.fitness.ActivityB"));
then in activityC:
double value=1.54354;
Bundle extras = getIntent().getExtras();
if(extras!=null){
value = extras.getDouble("clllo");
}
}
You could use the application context to hold your data.
Way to use app context.
Extend the ‘Application’ class and add a attribute to hold the different data which are needed in the different activities. So in your activity you can access the application context and get the data. As the application context is a singleton it will be the same instance in every activity.
In any other activity you can access that data the same way.
You also need to add
to ‘application’ tag in the manifest file.