Fragment to Activity to Fragment Communication
<p>I have two Frame Layouts(Containers) in my main.xml which contains two fragments. Now i want to pass a video url from FragmentOne to Activity and then Activity to FragmentTwo . I am unable to get the url in my second fragment. Below is my code,Please help me with the correct solution.</p>

<p>activity_main.xml

</p>

<pre><code>&lt;RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"&gt;

    &lt;FrameLayout
        android:layout_width="match_parent"
        android:id="@+id/top"
        android:layout_height="350dp"&gt;

    &lt;/FrameLayout&gt;

    &lt;FrameLayout
        android:layout_width="340dp"
        android:layout_marginTop="20dp"
        android:id="@+id/frgten"
        android:layout_below="@+id/top"
        android:layout_marginLeft="20dp"
        android:layout_marginRight="32dp"
        android:layout_height="130dp"/&gt;


&lt;/RelativeLayout&gt;
</code></pre>

<p>fragment_one.xml
</p>

<p>
</p>

<pre><code>&lt;RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"&gt;


    &lt;RelativeLayout
        android:layout_width="match_parent"
        android:layout_marginTop="15dp"
        android:id="@+id/rl1"
        android:layout_height="wrap_content"&gt;

        &lt;TextView
            android:layout_width="100dp"
            android:id="@+id/frg1"
            android:background="#c1a499"
            android:text="PLAY"
            android:textAlignment="center"
            android:layout_marginLeft="25dp"
            android:layout_height="100dp"
            android:autoLink="web"&gt;

        &lt;/TextView&gt;

        &lt;TextView
            android:layout_width="100dp"
            android:id="@+id/frg2"
            android:layout_marginLeft="10dp"
            android:background="#c1a499"
            android:text="PLAY"
            android:textAlignment="center"
            android:layout_toRightOf="@+id/frg1"
            android:layout_height="100dp"
            android:autoLink="web"&gt;

        &lt;/TextView&gt;

        &lt;TextView
            android:layout_width="100dp"
            android:id="@+id/frg3"
            android:background="#c1a499"
            android:text="PLAY"
            android:textAlignment="center"
            android:layout_marginLeft="10dp"
            android:layout_toRightOf="@+id/frg2"
            android:layout_height="100dp"
            android:autoLink="web"&gt;

        &lt;/TextView&gt;

    &lt;/RelativeLayout&gt;

    &lt;RelativeLayout
        android:layout_width="match_parent"
        android:id="@+id/rl2"
        android:layout_marginTop="15dp"
        android:layout_below="@+id/rl1"
        android:layout_height="wrap_content"&gt;

        &lt;TextView
            android:layout_width="100dp"
            android:id="@+id/frg4"
            android:background="#c1a499"
            android:text="PLAY"
            android:textAlignment="center"
            android:layout_marginLeft="25dp"
            android:layout_height="100dp"
            android:autoLink="web"&gt;

        &lt;/TextView&gt;

        &lt;TextView
            android:layout_width="100dp"
            android:id="@+id/frg5"
            android:background="#c1a499"
            android:text="PLAY"
            android:textAlignment="center"
            android:layout_marginLeft="10dp"
            android:layout_toRightOf="@+id/frg4"
            android:layout_height="100dp"
            android:autoLink="web"&gt;

        &lt;/TextView&gt;

        &lt;TextView
            android:layout_width="100dp"
            android:id="@+id/frg6"
            android:background="#c1a499"
            android:text="PLAY"
            android:textAlignment="center"
            android:layout_marginLeft="10dp"
            android:layout_toRightOf="@+id/frg5"
            android:layout_height="100dp"
            android:autoLink="web"&gt;

        &lt;/TextView&gt;

    &lt;/RelativeLayout&gt;

    &lt;RelativeLayout
        android:layout_width="match_parent"
        android:id="@+id/rl3"
        android:layout_below="@+id/rl2"
        android:layout_marginTop="15dp"
        android:layout_height="wrap_content"&gt;

        &lt;TextView
            android:layout_width="100dp"
            android:id="@+id/frg7"
            android:background="#c1a499"
            android:text="PLAY"
            android:textAlignment="center"
            android:layout_marginLeft="25dp"
            android:layout_height="100dp"
            android:autoLink="web"&gt;

        &lt;/TextView&gt;

        &lt;TextView
            android:layout_width="100dp"
            android:id="@+id/frg8"
            android:background="#c1a499"
            android:text="PLAY"
            android:textAlignment="center"
            android:layout_marginLeft="10dp"
            android:layout_toRightOf="@+id/frg7"
            android:layout_height="100dp"
            android:autoLink="web"&gt;

        &lt;/TextView&gt;

        &lt;TextView
            android:layout_width="100dp"
            android:id="@+id/frg9"
            android:background="#c1a499"
            android:text="PLAY"
            android:textAlignment="center"
            android:layout_marginLeft="10dp"
            android:layout_toRightOf="@+id/frg8"
            android:layout_height="100dp"
            android:autoLink="web"&gt;

        &lt;/TextView&gt;

    &lt;/RelativeLayout&gt;

&lt;/RelativeLayout&gt;
</code></pre>

<p></p>

<p>fragment_two.xml</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent"&gt;

    &lt;VideoView
        android:layout_width="match_parent"
        android:id="@+id/video"
        android:layout_height="match_parent" /&gt;

&lt;/LinearLayout&gt;
</code></pre>

<p>MainActivity</p>

<pre><code>import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

public class MainActivity extends AppCompatActivity implements FragmentOne.CommunicationChannel {

    private FragmentOne sendFragment=new FragmentOne();
    private FragmentTwo getFragment=new FragmentTwo();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        FragmentManager manager = getSupportFragmentManager();
        FragmentTransaction transaction = manager.beginTransaction();
        transaction.add(R.id.top,sendFragment);
        transaction.add(R.id.frgten,getFragment);
        transaction.commit();
    }

    @Override
    public void setCommunication(String url) {
        if(null != getFragment  &amp;&amp; getFragment.isInLayout())
        {
            getFragment.storeRecievedUrl(url);
        }

    }
}
</code></pre>

<p>FragmentOne</p>

<pre><code>import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;


/**
 * A simple {@link Fragment} subclass.
 */
public class FragmentOne extends Fragment {

    private CommunicationChannel mCommChListner=null;


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        final View view = inflater.inflate(R.layout.fragment_one, container, false);

        final TextView t1 = (TextView) view.findViewById(R.id.frg1);

        t1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                String url="http://www.androidbegin.com/tutorial/AndroidCommercial.3gp";
                sendUrl(url);
            }
        });
        return view;
    }

    interface CommunicationChannel
    {
        public void setCommunication(String url);
    }
    @Override
    public void onAttach(Activity activity)
    {
        super.onAttach(activity);
        if(activity instanceof CommunicationChannel)
        {
            mCommChListner = (CommunicationChannel)activity;
        }
        else
        {
            throw new ClassCastException();
        }

    }

    public void sendUrl(String url){
          mCommChListner.setCommunication(url);
    }

}
</code></pre>

<p>FragmentTwo</p>

<pre><code>import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;


/**
 * A simple {@link Fragment} subclass.
 */
public class FragmentTwo extends Fragment {


    public FragmentTwo() {
        // Required empty public constructor
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        final View view= inflater.inflate(R.layout.fragment_two, container, false);


        return view;
    }

    void storeRecievedUrl(String url){
        String VideoURL = url;

    }

}
</code></pre>