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.
Best way of calling Activity from Fragment class is that make interface in Fragment and add onItemClick() method in that interface. Now implement it to your first activity and call second activity from there.
Simply call your parent activity using getActivity() method.
If you make it a Fragment then change findViewById to v. findViewById . There is no findViewById function in Fragment so you have to call getView first then call findViewById on that. In your case though, you already have your view in onCreateView and that would be your variable v .
Get the parent activity using get activity then do as usual.
Intent myIntent = new Intent(getActivity().getapplicationcontext(), BookmarkActivity.class);
getActivity().startActivity(myIntent);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With