Code example for FragmentManager

Methods: beginTransactionfindFragmentById

0
  @Override 
  public void onCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState);
 
    FragmentManager fm = getSupportFragmentManager();
    if(fm.findFragmentById(android.R.id.content) == null){
      ArtistSearchFragment searchFrag = new ArtistSearchFragment();
      fm.beginTransaction().add(android.R.id.content, searchFrag).commit();
    } 
  } 
 
  /* 
  //Maybe later we'll allow them to switch up the artist 
  protected void onNewIntent(Intent intent){ 
    Log.d(TAG, "In on new intent"); 
    if(Intent.ACTION_SEARCH.equals(intent.getAction())){ 
      String searchQuery = intent.getStringExtra(SearchManager.QUERY); 
      getIntent().putExtra(SearchManager.QUERY, searchQuery); 
      getSupportLoaderManager().restartLoader( 
        SearchFragment.LIB_SEARCH_LOADER_TAG, null, searchFrag); 
Connect your IDE to all the code out there  Get Codota for Java