I would like to do a pretty simple task:
I got an activity A and an activity B.
Activity A contains an object that I want to change from activity B.
I tried to do so with following code:
Intent intent = new Intent(this, A.class);
FragmentManager fragmentManager = getSupportFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
fragmentTransaction.replace(R.id.fragment_container, new LogFragment());
fragmentTransaction.commit();
startActivity(intent);
Explanation:
fragment_container is the object I would like to replace by LogFragment (thats a fragment, speaking names for the win ^^ ).
This code doesn't work because he tells me that he can't find "fragment_container".
I guess thats because I am still in activity B while the "fragment_container" is found in activity A.
Is there a way how I can still address "fragment_container" while beeing in activity B? Another possibility could be that I would overwrite the startActivity method to something like startActivity(intent, fragment).
Is this possible and if yes, which methods do I need to overwrite? (I got basic java knowlegde but sadly no experience with android programming.)
Thanks for any help.