title: Android Alert Dialog not showing from a fragment inside a fragment
body: <p>I have the following scenaron in my Android App :</p>
  
  <p>after a splash screen i have an activity (MainActivity) with some clickable items , each item click starts a DrawerNavigationActivity with a fragment opened as like that </p>
  
  <pre><code>    CardView mediaTxt = findViewById(R.id.mediacardId);
      mediaTxt.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              Intent intent = new Intent(MainActivity.this, DrawerNavigationActivity.class);
              Bundle b = new Bundle();
              b.putInt("link", 2);
              intent.putExtras(b);
              startActivity(intent);
          }
      });
  </code></pre>
  
  <p>in the DraxerNavigationActivity i have that :</p>
  
  <pre><code>@Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_drawer_navigation);
      setTitle(R.string.app_name);
      //########################################################### set initial fragment
      if (savedInstanceState == null){
          Bundle b = getIntent().getExtras();
          Fragment fragment = null;
          if (b.getInt("link") == 1) {
              //fragment = new AgendaMainFragment();
              fragment = new ProgrammeFragment();
          } else if (b.getInt("link") == 2) {
              fragment = new MediaMainFragment();
          } else if (b.getInt("link") == 3) {
              fragment = new ThemesMainFragment();
          } else if (b.getInt("link") == 4) {
              fragment = new AdresseMainFragment();
          } else if (b.getInt("link") == 5) {
              fragment = new InfoMainFragment();
          } else if (b.getInt("link") == 6) {
              fragment = new NewsMainFragment();
          } else if (b.getInt("link") == 7) {
              fragment = new BlockMainFragment();
          } else if (b.getInt("link") == 8) {
              fragment = new DemosMainFragment();
          }
  
          FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
          ft.replace(R.id.frag_drawer_container, fragment);
          ft.commit();
      }
  
      Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
      setSupportActionBar(toolbar);
  
      DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
      ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
      drawer.addDrawerListener(toggle);
      toggle.syncState();
  
      NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
      navigationView.setNavigationItemSelectedListener(this);
  }
   @Override
  public boolean onNavigationItemSelected(MenuItem item) {
      Fragment fragment = null;
      // Handle navigation view item clicks here.
      int id = item.getItemId();
      if (id == R.id.nav_home) {
          //super.onBackPressed();
          //return true;
          startActivity(new Intent(DrawerNavigationActivity.this, MainActivity.class));
          return false;
      } else if (id == R.id.nav_agenda) {
          //fragment = new AgendaMainFragment();
          fragment = new ProgrammeFragment();
      } else if (id == R.id.nav_gallery) {
          fragment = new MediaMainFragment();
      } else if (id == R.id.nav_themes) {
          fragment = new ThemesMainFragment();
      } else if (id == R.id.nav_adresse) {
          fragment = new AdresseMainFragment();
      } else if (id == R.id.nav_info) {
          fragment = new InfoMainFragment();
      } else if (id == R.id.nav_news) {
          fragment = new NewsMainFragment();
      } else if (id == R.id.nav_blocs) {
          fragment = new BlockMainFragment();
      } else if (id == R.id.nav_demo_animation) {
          fragment = new DemosMainFragment();
      } else {
          return true;
      }
  
      FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
      ft.replace(R.id.frag_drawer_container, fragment);
      ft.commit();
  
      DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
      drawer.closeDrawer(GravityCompat.START);
      return true;
  }
  </code></pre>
  
  <p>and for MediaMainFragment i use a tabLyout and a FragmentStatePagerAdapter :</p>
  
  <pre><code>public class MediaMainFragment extends Fragment {
  ...
  @Override
  public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
  
  
      TabLayout tabLayout = getView().findViewById(R.id.tabsLayout);
      tabLayout.addTab(tabLayout.newTab().setText(getResources().getString(R.string.photos_ttr)));
      tabLayout.addTab(tabLayout.newTab().setText(getResources().getString(R.string.video_ttr)));
      tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);
  
      final ViewPager viewPager = getView().findViewById(R.id.pager);
      final PagerAdapter adapter = new PagerAdapter(getFragmentManager(), tabLayout.getTabCount());
      viewPager.setAdapter(adapter);
      viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
  
      tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
          @Override
          public void onTabSelected(TabLayout.Tab tab) {
              viewPager.setCurrentItem(tab.getPosition());
          }
  
          @Override
          public void onTabUnselected(TabLayout.Tab tab) {
          }
  
          @Override
          public void onTabReselected(TabLayout.Tab tab) {
          }
      });
  }
  </code></pre>
  
  <p>}</p>
  
  <p>in my PhotosFragment i am catching an exception and i want show a dialog alert  , the problm is that it's working if i load the PhotosFragment  from the drawer menu , but it's snot showing if it's loaded from MainActtivity.</p>
  
  <p>here is how i wanna show the dialog from PhotosFragment , it's a method inside PhotosFragment class </p>
  
  <pre><code>public String loadJSONFromAsset() {
      String json = null;
      try {
          File file = new File(getContext().getFilesDir(), "image.json");
          InputStream is = new FileInputStream(file);
          int size = is.available();
          byte[] buffer = new byte[size];
          is.read(buffer);
          is.close();
          json = new String(buffer, "UTF-8");
      } catch (IOException ex) {
          ex.printStackTrace();
  
          // check internet message dialog
          new DynamicDialog.Builder(getContext())
                  // Set dialog title.
                  .setTitle("test")
                  .setMessage("Check Internet")
                  .show();
  
          return null;
      }
      return json;
  }
  </code></pre>
  
  <p>i have a doubt about the context passed to to Builder , but i don't know how to fix that.</p>