首页 > 移动平台 > 详细

Android 调用系统的拍相程序进行录像

时间:2014-04-13 19:25:02      阅读:480      评论:0      收藏:0      [点我收藏+]

xml:

bubuko.com,布布扣
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:orientation="vertical"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent"
        >

    <Button
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="前往录像"
            android:onClick="click"
            />

</LinearLayout>
bubuko.com,布布扣

java:

bubuko.com,布布扣
package com.example.usingSystemCamera;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.provider.MediaStore;
import android.view.View;
import android.widget.Toast;

import java.io.File;

public class MyActivity extends Activity {

    private File file;//相片文件

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }

    /**
     * 界面按钮点击事件,跳转到系统录像机
     */
    public void click(View view) {
        Intent intent = new Intent();
        intent.setAction("android.media.action.VIDEO_CAPTURE");
        intent.addCategory("android.intent.category.DEFAULT");
        file = new File(Environment.getExternalStorageDirectory(), "myVideo.3gp");
        Uri uri = Uri.fromFile(file);
        intent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
        startActivityForResult(intent, 0);
    }

    /**
     * 提示
     */
    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        Toast.makeText(this,"录像成功!",1).show();
    }
}
bubuko.com,布布扣

 

 

Android 调用系统的拍相程序进行录像,布布扣,bubuko.com

Android 调用系统的拍相程序进行录像

原文:http://www.cnblogs.com/wuyou/p/3662283.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!