Android:从片段调用活动 [英] Android : Calling Activity from Fragment

查看:46
本文介绍了Android:从片段调用活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在活动中使用片段.我正在使用 MediaRecorder 进行录音.我有一个活动的两个部分.第一个本身将列出录制文件的活动.在它的右侧,当一个选择要为新文件录制时,调用查找活动.When the any of the listed file is selected i am using AudioPlayer as to play the recorded file.我在这里能够将活动转换为片段,但是当我按下停止时,它正在终止应用程序.

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.

推荐答案

使用 get 活动获取父活动,然后照常进行.

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

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

这篇关于Android:从片段调用活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆