Android  调用系统应用的方法总结

Android  调用系统应用的方法总结

1、调用系统拍照

Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
//保存到指定目录
File file = new File("/mnt/sdcard/picture");
if (!file.exists()) {
  file.mkdirs();
}
File out = new File("/mnt/sdcard/picture/123.jpg");
Uri uri = Uri.fromFile(out);
intent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1);
startActivityForResult(intent, 0);

2、调用系统录音

Intent intent = new Intent(MediaStore.Audio.Media.RECORD_SOUND_ACTION);
startActivityForResult(intent, 1);

3、调用系统录像

Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 0.5);//画质0.5
intent.putExtra(android.provider.MediaStore.EXTRA_SIZE_LIMIT,768000);
intent.putExtra(MediaStore.EXTRA_DURATION_LIMIT, 70000);//70s
File file = new File("/mnt/sdcard/video");
if (!file.exists()) {
   file.mkdirs();
}
File tmpFile = new File("/mnt/sdcard/video/123.mp4");
Uri outputFileUri = Uri.fromFile(tmpFile);
// 设置视频的品质为高
mIntent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1);
// 设置视频文件名
mIntent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
startActivityForResult(mIntent, 2);

4、直接打开图库

Intent i = new Intent(
Intent.ACTION_PICK,
android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(i, RESULT_LOAD_IMAGE);

5、打开图库和文件夹选项

Intent intent = new Intent();intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(intent, PIC);

以上就是Android调用系统应用的方法总结,如有疑问请留言或者到本站社区交流讨论,感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!

(0)

相关推荐

  • android隐式意图激活自定义界面和系统应用界面的实例

    我们也可以使用隐士意图激活自定义的界面,并且可以携带数据: 效果: 点击第二个按钮后: 点击最后一个按钮(激活系统短消息界面)后: 附代码: 主窗体的代码: package com.yy.twoactivity; import android.app.Activity; import android.content.Intent; import android.net.Uri; import android.os.Bundle; import android.view.View; public

  • Android使用Intent启动其他非系统应用程序的方法

    本文实例讲述了Android使用Intent启动其他非系统应用程序的方法.分享给大家供大家参考,具体如下: android应用程序内部通过Intent来实现Activity间的跳转.也知道通过Intent调用系统程序.但若想在应用程序A内开启应用程序B(前提是A.B均已安装),该如何去实现? 记录下实现过程. 在应用程序A内添加如下代码: Intent i = new Intent(); i.setClassName("com.example.a", "com.example

  • Android 调用系统应用的方法总结

    Android  调用系统应用的方法总结 1.调用系统拍照 Intent intent = new Intent("android.media.action.IMAGE_CAPTURE"); //保存到指定目录 File file = new File("/mnt/sdcard/picture"); if (!file.exists()) { file.mkdirs(); } File out = new File("/mnt/sdcard/picture

  • Android  调用系统应用的方法总结

    Android  调用系统应用的方法总结 1.调用系统拍照 Intent intent = new Intent("android.media.action.IMAGE_CAPTURE"); //保存到指定目录 File file = new File("/mnt/sdcard/picture"); if (!file.exists()) { file.mkdirs(); } File out = new File("/mnt/sdcard/picture

  • Android调用系统自带浏览器打开网页的实现方法

    在Android中可以调用自带的浏览器,或者指定一个浏览器来打开一个链接.只需要传入一个uri,可以是链接地址. 启动android默认浏览器 在Android程序中我们可以通过发送隐式Intent来启动系统默认的浏览器.如果手机本身安装了多个浏览器而又没有设置默认浏览器的话,系统将让用户选择使用哪个浏览器来打开连接. Uri uri = Uri.parse("https://www.baidu.com"); Intent intent = new Intent(Intent.ACTI

  • Android 调用系统相机拍摄获取照片的两种方法实现实例

    Android 调用系统相机拍摄获取照片的两种方法实现实例 在我们Android开发中经常需要做这个一个功能,调用系统相机拍照,然后获取拍摄的照片.下面是我总结的两种方法获取拍摄之后的照片,一种是通过Bundle来获取压缩过的照片,一种是通过SD卡获取的原图. 下面是演示代码: 布局文件: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http:

  • Android调用系统默认浏览器访问的方法

    一.启动android默认浏览器 这样子,android就可以调用起手机默认的浏览器访问. 二.指定相应的浏览器访问 1.指定android自带的浏览器访问 ( "com.android.browser":packagename :"com.android.browser.BrowserActivity":启动主activity) Intent intent= new Intent(); intent.setAction("android.intent.a

  • Android调用系统照相机拍照与摄像的方法

    前言 在很多场景中,都需要用到摄像头去拍摄照片或视频,在照片或视频的基础之上进行处理.但是Android系统源码是开源的,很多设备厂商均可使用,并且定制比较混乱.一般而言,在需要用到摄像头拍照或摄像的时候,均会直接调用系统现有的相机应用,去进行拍照或摄像,我们只取它拍摄的结果进行处理,这样避免了不同设备的摄像头的一些细节问题.本篇博客将介绍在Android应用中,如何调用系统现有的相机应用去拍摄照片与短片,并对其进行处理,最后均会以一个简单的Demo来演示效果. 1.系统现有相机应用的调用 对于

  • Android调用系统图片裁剪限定尺寸及7.0照相问题的解决方法

    本文实例为大家分享了Android调用系统图片裁剪限定尺寸及7.0照相问题的解决方法,供大家参考,具体内容如下 内容:手机系统的裁剪介绍,7.0调用相机崩溃解决 代码如下: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="h

  • Android调用系统裁剪的实现方法

    Android调用系统裁剪,这个已经使用的很熟悉了.但是近期项目里使用的时候遇到了一些小问题,所以在此整理一下,以作记录. 首先看代码: Intent intent1 = new Intent("com.android.camera.action.CROP"); intent1.setDataAndType(Uri.fromFile(new File(image.path)), "image/*"); intent1.putExtra("crop"

  • Android调用系统图库获取图片的方法

    本文实例为大家分享了Android调用系统图库获取图片的具体代码,供大家参考,具体内容如下 1.开发工具与关键技术:Eclipse.AndroidStudio2.撰写时间:2020年05月28日 在做移动开发相信很多人都会用到调用系统的图库获取图片吧,那么今天我跟大家讲讲如何调用系统的图库获取图片呢!由于本次的内容有点多,所以,分几个步骤吧!废话就不多说啦!避免浪费大家的时间,回归正题.请看代码 第一步:在build.gradle的文件下确保安卓版本是6.0以上(targetSdkVersion

  • Android调用系统摄像头拍照并显示在ImageView上

    简介 现在市面上的apk只要涉及用户中心都会有头像,而且这个头像也是可自定义的,有的会采取读取相册选择其中一张作为需求照片,另一种就是调用系统摄像头拍照并获取即时照片,本博文就是讲述如何调用摄像头拍照并显示在指定的控件上. 先来看看效果图 由于这里我用的是模拟器没有摄像头,所以拍照是黑的,至于里面2个红色圆圈那是Genymotion自带的标志. 实现起来比较简单: activity_main.xml <?xml version="1.0" encoding="utf-8

随机推荐