Back to project page streaming_project.
The source code is released under:
GNU General Public License
If you think the Android project streaming_project listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.example.streaming.streaming; /* w w w. j a v a 2 s .co m*/ import android.os.Bundle; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentManager; // Abstract Activity class // Every activity will require the same code so they will all be a subclass of // SingleFragmentActivity // NOTE 1: the layout that gets inflated is not-hardcoded so that MediaListActivity can inflate // a single-container layout on phones and a two-container layout on tablets (i.e. a master-detail // interface) // NOTE 2: if a SingleFragmentActivity's subclass wants to inflate a layout other than // activity_fragment.xml, it must override getLayoutResId() to return a layout other than the // default one (activity_fragment.xml) public abstract class SingleFragmentActivity extends FragmentActivity { // createFragment() is an abstract method. The subclasses from SingleFragmentActivity must // implement it. protected abstract Fragment createFragment(); @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(getLayoutResId()); FragmentManager fm = getSupportFragmentManager(); Fragment fragment = fm.findFragmentById(R.id.fragmentContainer); if (fragment == null) { fragment = createFragment(); fm.beginTransaction() .add(R.id.fragmentContainer, fragment) .commit(); } } // Returns the ID of the layout that the activity will inflate // NOTE: SingleFragmentActivity subclasses can choose to override getLayoutResId() to return a // layout other than activity_fragment.xml protected int getLayoutResId() { return R.layout.activity_fragment; } }