You need to create a new fragment, and add the functionality from the activity’s life cycle to the fragment’s life cycle.
For example:
your activity’s onCreate()’s code should be implemented in onCreateView() of the fragment, off course you’ll have to change some stuff like inflatting the view and returning it instead of calling setContentView(R.layout.id).
Implement it also for onResume(), onStop(), onPause() etc..
Then you’ll need to implement a FragmentActivity and create and attach this fragment to it( you can do it from the xml or from the code), you can find out here how to do that.
4
solved How convert my existing activities to fragment with the same functionality and layout?