Pass data from Activity to Fragment that is already displayed

pass data from activity to fragment using interface
fragment to fragment communication without activity
android pass arguments to fragment
pass data from activity to fragment in viewpager
pass data from activity to fragment kotlin
how to pass intent from activity to fragment in android
pass data from fragment to fragment
pass data between fragments in same activity

How do you pass a data from activity to fragment that's already active? I can transfer using a bundle but the only way I can get it is using createView on that fragment but my problem is it is already created. Is there anyway that I can pass data from activity to fragment and then call that data without using onCreateView

I tried this link to get what I needed but the data is not accessible due to static

If view is already created then onCreateview will not call so you can pass data via BroadcastReceiver

 BroadcastReceiver receiverUpdateDownload = new BroadcastReceiver() {
        public void onReceive(Context context, Intent intent) {
            //Getdata from intent

Regester your BroadcastReceiver in onCreateView

IntentFilter filter = new IntentFilter("STRING_ID_FOR_BRODCAST");
getActivity().registerReceiver(receiverUpdateDownload, filter);

unregister your Receiver at onStop

public void onStop() {
    if (receiverUpdateDownload != null) {
        try {
        } catch (Exception e) {

Call your brodcast from acttvity

 Intent intent = new Intent("STRING_ID_FOR_BRODCAST");

Passing Data Between Fragments to Activity, How do you pass data from activity to fragment using intent? Today we are going to learn how to pass data from Activity to Fragment. Before starting this tutorial just go through Fragments Tutorial if you are new to Fragments. For passing data from activity to fragment you can follow some steps given below: Bundle – Bundle is a mapping from String values to various Parcelable types.

How to Pass Data from One Activity to Another in Android, is passed in key value pair. The value can be of types like int, float, long, string, etc. In this tutorial we are going to learn how to pass data between Fragments in an Activity class. In my previous android tutorial we cover how to use Fragment in android Studio IDE and we went further to learn how we can pass data from a Fragment to its host Activity with Interface.

According to documentation :

The host activity can deliver messages to a fragment by capturing the Fragment instance with findFragmentById(), then directly call the fragment's public methods.

Example (declare this in your activity):

ArticleFragment articleFrag = (ArticleFragment)

        if (articleFrag != null) {
            // If article frag is available
            // Call a method in the ArticleFragment to update its content

And in your fragment implement the method that will do the trick.

Android Pass Data from Activity to Fragment, For passing data from activity to fragment you can follow some steps given below: Bundle Duration: 0:17 Posted: Oct 12, 2015 When we want to pass data between fragments, we are doing it with the help of the Activity which contains these fragments. In our example, the Activity is the MainActivity.kt. So we are going to use the MainActivity to pass the data from the first to the second fragment using an interface.

#3-Passing data from Activity to Fragment in android studio., This video shows how to pass data from Activity to Fragments.Duration: 14:41 Posted: Jan 16, 2018 I don't know if this is the best way or not Bu I have been searching on google for quite a while finding how can I pass a Bundle from a fragment to its container activity but all I found was sending data from activity to fragment instead (which was a bit confusing for me as I'm a newbie).

Android, All fragments should have an empty constructor (i.e. a constructor method having no input arguments). Therefore, in order to pass your data to the Fragment  Im trying to find a way to pass a value on the event. So say I have a list item, and onListItemClick on fragment A, I need to pass a value to fragment B, or to the activity, then pass the uri to fragment b. But, how do I pass the string between fragment A, activity, then fragment B? This also seems like avery inefficient way of doing this.

How to pass data from activity to fragment in android, So the technique is very similar to send data to activity. For sending the data to fragment we use the Bundle. Bundles: A mapping from String keys  Today we want to see how to pass data from an activity to a fragment. We’ll use a Bundle object, pack data to it in our Activity, then unpack that data inside the onCreateView() method of our Fragment.