Android : Calling Activity from Fragment

Dharma Cool picture Dharma Cool · Sep 28, 2012 · Viewed 83.4k times · Source

I am using fragments inside an activity. I am using MediaRecorder to for audio recording. I have two part of an activity. 1st itself the Activity which will list the recorded file. On it's right side the AudioRecording Activity is called when one select to record for a new file. When the any of the listed file is selected i am using AudioPlayer as to play the recorded file. I am here able to convert the Activity into fragment but when i press on Stop it is terminating the application.

Please anyone can answer. My audiorecorder is working fine when i use it as simple activity. Any solution like if i can call that activity in that fragment or something like that.? Please help me if anyone knows.

Answer

Chinmoy Debnath picture Chinmoy Debnath · Sep 28, 2012

Get the parent activity using get activity then do as usual.

Intent myIntent = new Intent(getActivity().getapplicationcontext(), BookmarkActivity.class);
getActivity().startActivity(myIntent);