Actually your question is not related to:
I need to pass data from activity to fragmenet .I know I can use
bundle , but one i've passed data , I cant send anymore data without
calling and creating fragment once more .
The real one is this:
in my activity , some thing may be changed and I need to notify my
fragment from these changes without recreating fragment.
how can I do so ?
In this case I would store the fragment in the activity as reference and I would call a function, an interface implementation inside the fragment.
Something like this:
In Activity:
SomeEventListener myFragment ;
yourFragmentCreationMethod(){
if(myFragment == null){
myFragment = new MyFragment(maybeParamsHere);
}
}
yourNotificationMethod(){
myFragment .onEventHappent(param);
}
// declare an interface: - separate file
public interface SomeEventListener
{
void onEventHappent(param);
}
// implement the interface in Fragment - separate file
public class MyFragment extends Fragment implements SomeEventListener{
// add a constructor what you like
public void onEventHappent(param){
/// ... your update
}
}
The interface it will help you at testing only.