zoukankan      html  css  js  c++  java
  • 调用相机,录像机

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:paddingBottom="@dimen/activity_vertical_margin"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:paddingTop="@dimen/activity_vertical_margin"
        tools:context="com.example.lenovo.service.XiangjiActivity"
        android:orientation="vertical">
    
        <Button
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:onClick="bt_1"
            android:text="相机"/>
        <Button
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:onClick="bt_2"
            android:text="录像机"/>
    
    </LinearLayout>
    activity
    package com.example.lenovo.service;
    
    import android.content.Intent;
    import android.net.Uri;
    import android.os.Environment;
    import android.provider.MediaStore;
    import android.support.v7.app.AppCompatActivity;
    import android.os.Bundle;
    import android.view.View;
    
    import java.io.File;
    
    public class XiangjiActivity extends AppCompatActivity {
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_xiangji);
        }
        public void bt_1(View v)
        {
            Intent intent=new Intent();
            intent.setAction("android.media.action.IMAGE_CAPTURE");
            intent.addCategory("android.intent.category.DEFAULT");
            File file=new File(Environment.getExternalStorageDirectory()+"/000.jpg");
            Uri uri=Uri.fromFile(file);
            intent.putExtra(MediaStore.EXTRA_OUTPUT,uri);
            this.startActivity(intent);
        }
    
        public void bt_2(View v)
        {
            Intent intent=new Intent();
            intent.setAction("android.media.action.VIDEO_CAPTURE");
            intent.addCategory("android.intent.category.DEFAULT");
            File file=new File(Environment.getExternalStorageDirectory()+"/000.3gp");
            Uri uri=Uri.fromFile(file);
            intent.putExtra(MediaStore.EXTRA_OUTPUT,uri);
            this.startActivity(intent);
        }
    
    }
    java
  • 相关阅读:
    关于SubSonic3.0查询或更新时出现System.NullReferenceException异常的处理
    SubSonic3.0使用例子
    Hive:ORC File Format存储格式详解
    HiveQL之Sort by、Distribute by、Cluster by、Order By详解
    Hive之import和export使用详解
    手动安装cloudera manager 5.x(tar包方式)详解
    初次安装hive-2.1.0启动报错问题解决方法
    LAMP下安装zabbix流水
    ESXI虚拟机磁盘管理(精简-厚置-精简)
    VMware esxi 5.5装机方案
  • 原文地址:https://www.cnblogs.com/1ming/p/5643127.html
Copyright © 2011-2022 走看看