title: Go back from activity to fragment with Up button
body: <p>In main activity i've created two fragments used as tabbed menu. One of the fragments contains a list where list items starts a new activity when clicked. I wanna go back from new activity to the fragment (list) using the Up Action/Navigation button but no list is displayed, only an empty tab. I have declared parent activity as the main activity in manifest.xml. </p>
  
  <p>When i use phone's back button it works fine. </p>
  
  <p>List is created in fragment's onViewCreated method.</p>
  
  <p>Manifest :
  </p>
  
  <pre><code>&lt;application
      android:allowBackup="true"
      android:icon="@mipmap/ic_launcher"
      android:label="@string/app_name"
      android:supportsRtl="true"
      android:theme="@style/AppTheme"&gt;
      &lt;activity
          android:name=".MainActivity"
          android:label="@string/app_name"
          android:theme="@style/AppTheme.NoActionBar"&gt;
          &lt;intent-filter&gt;
              &lt;action android:name="android.intent.action.MAIN" /&gt;
  
              &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
          &lt;/intent-filter&gt;
      &lt;/activity&gt;
      &lt;activity
          android:name=".Main2Activity"
          android:parentActivityName=".MainActivity" &gt;
      &lt;/activity&gt;
  &lt;/application&gt;
  </code></pre>
  
  <p></p>
  
  <p>Fragment with listView which start the new activity :</p>
  
  <pre><code> public static class frag extends Fragment {
  
      private static final String ARG_SECTION_NUMBER =   "section_number";
  
      public frag() {
      }
      public static frag newInstance(int sectionNumber) {
          frag fragment = new rangingFrag();
          Bundle args = new Bundle();
          args.putInt(ARG_SECTION_NUMBER, sectionNumber);
          fragment.setArguments(args);
          return fragment;
      }
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
                               Bundle savedInstanceState) {
          View rootView = inflater.inflate(R.layout.fragment_main, container, false);
  
  
          return rootView;
      }
  
      @Override
      public void onViewCreated(View rootView, Bundle savedInstanceState) {
          ListView listView = (ListView) rootView.findViewById(R.id.mobile_list);
          final ArrayAdapter adapter = new ArrayAdapter&lt;&gt;(getActivity().getApplicationContext(), R.layout.listview);
          listView.setAdapter(adapter);
          adapter.addAll(beacons);
  
          listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                                              public void onItemClick(AdapterView&lt;?&gt; parent, View v,
                                                                      int position, long id) {
                                                  String selectedText = (String) parent.getItemAtPosition(position);
                                                  Bundle bundle = new Bundle();
                                                  bundle.putString("param1", selectedText);
                                                  Intent myIntent = new Intent(v.getContext(), Main2Activity.class);
                                                  myIntent.putExtras(bundle);
                                                  startActivity(myIntent);
                                              }
                                          }
          );
  
      } }
  </code></pre>