mARecorder.setOutputFormat(MediaRecorder.OutputFormat.RAW_AMR); //设置音频文件的编码

mARecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB); //设置audio格式

xml大致如下(重复的省略了)

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android=“http://schemas.android.com/apk/res/android”

android:orientation=“vertical” android:layout_width=“match_parent”

android:layout_height=“match_parent”

android:background="@drawable/bg">

<RelativeLayout

android:id="@+id/rl"

android:layout_width=“match_parent”

android:layout_height=“45dp”

android:background="#0000">

<Button

android:id="@+id/bt_back"

android:layout_width=“40dp”

android:layout_height=“40dp”

android:layout_alignParentLeft=“true”

android:layout_margin=“5dp”

android:background="@drawable/back_bg"

android:onClick=“onBack”/>

<TextView

android:id="@+id/tv_title"

android:layout_width=“wrap_content”

android:layout_height=“35dp”

android:gravity=“center_vertical”

android:text=“分贝测试”

android:textColor="@android:color/white"

android:layout_centerHorizontal=“true”

android:textSize=“20dp”

android:layout_centerVertical=“true”/>

<LinearLayout

android:id="@+id/linearLayout1"

android:layout_width=“match_parent”

android:layout_height=“200dp”

android:gravity=“center”

android:orientation=“horizontal”>

<ImageView

android:id="@+id/iv_record_wave_left"

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”

android:layout_margin=“5dp”

android:background="@drawable/record_wave_left" />

<TextView

android:id="@+id/textView1"

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”

android:textColor="@android:color/holo_red_light"

android:textSize=“40sp”

android:text=“0.00”

android:textStyle=“bold”/>

<TextView

android:id="@+id/textView2"

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”

android:text=“dB”

android:textColor="@android:color/holo_red_light"

android:textSize=“40sp”

android:textStyle=“bold”/>

<ImageView

android:id="@+id/iv_record_wave_right"

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”

android:layout_margin=“5dp”

android:background="@drawable/record_wave_right" />

<ScrollView

android:id="@+id/absclv"

android:layout_width=“match_parent”

android:layout_height=“match_parent”

android:layout_below="@id/rl"

android:focusable=“false”

android:focusableInTouchMode=“true”

android:background="@android:color/white">

<LinearLayout

android:layout_width=“match_parent”

android:layout_height=“match_parent”

android:orientation=“vertical”>

<LinearLayout

android:layout_width=“match_parent”

android:layout_height=“wrap_content”

android:orientation=“horizontal”

android:padding=“10dp”>

<TextView

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”

android:text=“10dB”

android:textColor="@android:color/holo_green_light"

android:textSize=“20dp”

android:textStyle=“bold” />

<TextView

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”

android:layout_marginLeft=“10dp”

android:text=“呼吸声”

android:textColor="@android:color/darker_gray"

android:textSize=“20sp”/>

<View

android:layout_width=“wrap_content”

android:layout_height=“1dp”

android:background="@android:color/darker_gray"/>

。。。。

分贝值旁边的两个小喇叭是有动画效果的animation-list

接下来是 MicDemoActivity 完成开启麦克风接收音量功能

package com.rikka.toolbox;

import android.app.Activity;

import android.graphics.drawable.AnimationDrawable;

import android.media.MediaRecorder;

import android.os.Bundle;

import android.os.Environment;

import android.os.Handler;

import android.os.Message;

import android.support.annotation.Nullable;

import android.util.DisplayMetrics;

import android.util.Log;

import android.view.View;

import android.view.WindowManager;

import android.widget.ImageView;

import android.widget.TextView;

import java.io.File;

import java.io.IOException;

import java.text.DecimalFormat;

public class MicDemoActivity extends Activity {

private MicroPhoneThread microPhone = new MicroPhoneThread(); //线程用于实时录制周围声音

public boolean istrue = true;

private MediaRecorder mARecorder; //麦克风控制

最后

如果你看到了这里,觉得文章写得不错就给个赞呗?如果你觉得那里值得改进的,请给我留言。一定会认真查询,修正不足。谢谢。

最后针对Android程序员,我这边给大家整理了一些资料,包括不限于高级UI、性能优化、移动架构师、NDK、混合式开发(ReactNative+Weex)微信小程序、Flutter等全方面的Android进阶实践技术;希望能帮助到大家,也节省大家在网上搜索资料的时间来学习,也可以分享动态给身边好友一起学习!

需要资料的朋友可以点击我的GitHub免费领取

r等全方面的Android进阶实践技术;希望能帮助到大家,也节省大家在网上搜索资料的时间来学习,也可以分享动态给身边好友一起学习!

需要资料的朋友可以点击我的GitHub免费领取

Android 分贝测试仪功能,华为移动终端开发相关推荐

  1. Android 分贝测试仪功能,你会的还只有初级Android工程师的技术吗

    android:textSize="40sp" android:textStyle="bold"/> <ImageView android:id=& ...

  2. Android SDK包功能介绍,中文开发API

    Android 包索引 这些是API包. 查看全部 API classes . android 包含平台中包含的应用程序使用的资源类,并定义系统功能的应用程序权限. android.accessibi ...

  3. android盲人模式功能,华为P9盲人模式功能介绍 华为P9手机 talkback使用图文教程...

    华为P9搭载的是基于安卓6.0深度定制的EMUI 4.1系统,很多人可能没有注意到P9手机系统辅助功能里面多了两个功能:TalkBack和开关控制.今天我们主要来说说TalkBack是什么,如何使用t ...

  4. android实现电话功能实验报告,安卓开发实验报告-20210407005833.docx-原创力文档

    文档编制序号:[KKIDT-LLE0828-LLETD298-POI08] 文档编制序号:[KKIDT-LLE0828-LLETD298-POI08] 安卓开发实验报告 安卓开发实验报告 目录 页面跳 ...

  5. Android扫码功能--华为统一扫码服务

    提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档 文章目录 前言 一.华为统一扫码服务是什么? 二.使用步骤 1.准备工作 2.开启扫码功能 3.自定义扫码页面 4.同时识别多个二维码 ...

  6. 华为设置android系统提醒功能,华为手机短信不提醒怎么办?华为手机短信提醒设置方法...

    华为手机短信提醒设置方法 1)检查当前设置的默认短信应用是哪个应用. ①点击桌面"设置"图标②找到"应用程序管理" ③选择"默认应用设置"④ ...

  7. 华为设置android系统提醒功能,华为Watch GT智能手表怎么设置消息提醒功能

    华为最近上线发售了一款智能手表-Watch GT,这款产品可能是很多粉丝期待已久的了.而很多用户订购之后回去可能有些问题不会使用,比如怎么设置华为Watch GT的消息提醒功能.接下来小编给大家带来相 ...

  8. 华为设置android系统提醒功能,华为Watch GT2消息提醒怎么设置?短信微信消息提醒设置方法...

    华为Watch GT2是一款物美价廉的智能手表,同样也是一款非常实用的运动手表,那么华为watch gt2怎么设置消息提醒呢,为了不让大家错过手表上的短信.QQ和微信消息提醒,今天智能手机网小编就来分 ...

  9. 大数据开发方向分享:春招获蚂蚁金服、拼多多、华为(终端)、远景能源、华泰证券等offer

    大数据开发方向分享:春招获蚂蚁金服.拼多多.华为(终端).远景能源.华泰证券等offe 一.背景 2020届985硕士,投的基本是上海岗位,非科班转行大数据开发方向和Java后端开发. 参加了2020 ...

  10. Android高级终端开发学习笔记(《疯狂Android讲义》第11章-第17章)

    Android高级终端开发笔记 2021/6/19 下午 13:34开始 多媒体应用开发 Android支持的音频格式有:MP3 WAV 3GP等.支持的视频格式有MP4 3GP等. 多媒体数据既可以 ...

最新文章

  1. hbase1.1.1 连接集群_除了HAProxy,RabbitMQ集群还可以这样用
  2. Ajax -get 请求
  3. 通过WebBrowser使用Echats
  4. 在加拿大读大学被开除了,以后该怎么办?
  5. 一种基于随机投影的本地差分隐私高维数值型数据收集算法
  6. java骨架_基于Mat变换的骨架提取Java
  7. Linux “百变”秀:今天 Windows 95,明天 Mac OS 9
  8. mysql 面试知识点笔记(三)联合索引的最左匹配原则
  9. NVIDIA驱动版本、Pytorch版本、Cuda版本三者之间对应的版本关系
  10. Android实现思维导图功能,Android实现思维导图
  11. 从三本院校到斩获字节跳动后端研发Offer
  12. Linux 中防火墙命令
  13. 如何提高kettle在大数据量下的读写速度
  14. 小鑫の日常系列故事(一)——判断对错
  15. android查看显存大小,Shadow Size Computation 阴影大小计算
  16. 喜欢这样的游戏---流畅的俯视坦克射击游戏
  17. PowerShell:无法加载文件 XXXXXXX,因为在此系统上禁止运行脚本
  18. zulip 开源聊天软件服务器搭建
  19. 长知识啦——自己动手写分类模型
  20. pfamscan 的使用_蛋白编码能力预测软件pfam流程

热门文章

  1. IDEA 常用插件安装
  2. idea安装插件gitee、插件商店里搜不到插件?
  3. java数字转大写_java实现数字转大写的方法
  4. 毕业设计3-BME280温湿度大气压传感器调试记录(STM32F103C8T6 + STM32CubeMX + BME280)
  5. 冒烟测试、回归测试、随机测试、探索性测试和安全测试
  6. uniapp H5 扫码 扫一扫 功能
  7. 《Python实用爬虫案例》练习8:获取搜狗搜索引擎微信文章
  8. 好用的PDF编辑软件有哪些?这几款工具建议收藏
  9. windows便签工具在哪 windows11的便签在哪里打开
  10. 1%大气密度也能飞?NASA把无人机送上火星,最具野心探测计划启动