录制视频后的完成活动(使用CWAC-Camera库)

时间:2014-11-29 03:40:35

标签: android android-activity android-camera commonsware-cwac cwac-camera

我正在开发一个应用程序,它会自动调用一个活动来每隔几秒钟拍摄一次视频。

活动从服务开始,如下所示。

Intent intent1 = new Intent(context,CwacCamActivity.class);
intent1.setAction(GlobalVariables.TAKE_VIDEO_ACTION);
intent1.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent1.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);//have tried without including this too.
context.startActivity(intent1);

根据有关开始录制视频的最佳时间的建议,

我开始录制视频

public void autoFocusAvailable()

这是代码

try {
    record();
} catch (Exception e) {
    e.printStackTrace();
}

//THread to stop the video after stipulated time ( 5 seconds for example)...
new Thread(new Runnable() {
    @Override
    public void run() {
        //RUnnable to let the record go on for the requested time...

            try {
                Thread.sleep(5000);
                getActivity().runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        try {
                            stopRecording();
                            getActivity().finish();    
                        } catch (IOException e) {
                            e.printStackTrace();
                            Log.v(GlobalVariables.TAG,"error is"+e.getMessage());
                        }    
                    }
                });
            } catch (Exception e) {
                Log.v(GlobalVariables.TAG,"error is"+e.getMessage()
            }
    }
}).start();

当我通过将活动设置为MAIN和Launcher来尝试上述代码时,它完全关闭但是当从服务运行活动时,它会不断重新启动活动并且整个应用程序崩溃过程

在拍照时,在SavePicture()中完成活动是有意义的。我不确定这是否是完成活动的正确位置,甚至是停止录制。但是,停止录制工作并保存视频正如他们应该的那样。

我尝试了很多不同的东西,但无济于事。我觉得我错过了很简单的东西。

任何帮助都表示赞赏,因为我现在没有想法。

0 个答案:

没有答案