|—x86
|—PLACEHOLDER
|—res
|—drawable-xxxhdpi
|—btn_end_call.png
|—btn_mute.png
|—btn_switch_camera.png
|—btn_video.png
|—btn_voice.png
|—ic_launcher.png
|—layout
|—activity_video_chat_view.xml
|—values
|—colors.xml
|—dimens.xml
|—strings.xml
|—styles.xml
|—build.gradle
|—gradle
|—wrapper
|—gradle-wrapper.jar
|—gradle-wrapper.properties
|—gradle.properties
|—gradlew
|—gradlew.bat
|—images
|—ActivityViewChat.png
|—LICENSE.md
|—README.md
|—README.zh.md
|—settings.gradle
settings.gradle
和build.gradle
(最外层)如果你想导入AS中查看,可以看一下
com.android.tools.build:gradle
的版本修改一下
---->[settings.gradle]----------------看一下项目包含的模块------------
include ‘:app’
---->[build.gradle]----------------看一下项目的一些信息------------
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath ‘com.android.tools.build:gradle:3.1.4’
}
}
allprojects {
repositories {
jcenter()
google()
}
}
task clean(type: Delete) {
d
《Android学习笔记总结+最新移动架构视频+大厂安卓面试真题+项目实战源码讲义》
【docs.qq.com/doc/DSkNLaERkbnFoS0ZF】 完整内容开源分享
elete rootProject.buildDir
}
模块下的build.gradle
---->[app/build.gradle]----------------看一下项目的具体信息------------
apply plugin: ‘com.android.application’
android {
compileSdkVersion 26
defaultConfig {
applicationId “io.agora.tutorials1v1vcall”
minSdkVersion 16
targetSdkVersion 26
versionCode 1
versionName “1.0”
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile(‘proguard-android.txt’), ‘proguard-rules.pro’
}
}
sourceSets {//这里是jniLibs的目录
main {
jniLibs.srcDirs = [’…/…/…/libs’]
}
}
}
dependencies {//这里是依赖
implementation fileTree(dir: ‘…/…/…/libs’, include: [’*.jar’]) // DO NOT CHANGE, CI may needs it when packaging
implementation ‘com.android.support:appcompat-v7:26.1.0’
}
AndroidManifest.xml
,得到入口Activity可见示例的入口是
VideoChatViewActivity
,并看一下权限
|— 权限 ------------
项目的配置如图,将依赖包以及.so文件放在对应位置
为了方便些,将res文件夹的资源拷贝一下
一共也就200多行,还包括一大坨权限申请的代码,这里权限申请的代码单独拎出来,就当复习一下。
---->[成员变量]----------------------------------
private static final int PERMISSION_REQ_ID = 22;
//WRITE_EXTERNAL_STORAGE 权限只是为了保存日志到SD卡
private static final String[] REQUESTED_PERMISSIONS = {
Manifest.permission.RECORD_AUDIO,//录音权限
Manifest.permission.CAMERA,//相机权限
Manifest.permission.WRITE_EXTERNAL_STORAGE//SD卡写权限
};
if (checkSelfPermission(REQUESTED_PERMISSIONS[0], PERMISSION_REQ_ID) &&
checkSelfPermission(REQUESTED_PERMISSIONS[1], PERMISSION_REQ_ID) &&
checkSelfPermission(REQUESTED_PERMISSIONS[2], PERMISSION_REQ_ID)) {
//执行到此处说明已有权限成功
initAgoraEngineAndJoinChannel();
}
/**
@Override
public void onRequestPermissionsResult(
int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
Log.i(LOG_TAG, "onRequestPermissionsResult " + grantResults[0] + " " + requestCode);
switch (requestCode) {
case PERMISSION_REQ_ID: {//请求码
if (grantResults[0] != PackageManager.PERMISSION_GRANTED ||
grantResults[1] != PackageManager.PERMISSION_GRANTED ||
grantResults[2] != PackageManager.PERMISSION_GRANTED) {
//三个权限有任意的未被允许,弹吐司,退出
showLongToast("Need permissions " +
Manifest.permission.RECORD_AUDIO + “/” +
Manifest.permission.CAMERA + “/” +
Manifest.permission.WRITE_EXTERNAL_STORAGE);
finish();
break;
}
//执行到此处说明用户已允许权限
initAgoraEngineAndJoinChannel();
break;
}
}
}
/**
/**
/**
/**
/**
IRtcEngineEventHandler
IRtcEngineEventHandler是一个抽象类,定义了非常多的抽象方法还有一些静态内部类
private final IRtcEngineEventHandler mRtcEventHandler = new IRtcEngineEventHandler() {
@Override//已完成远端视频首帧解码回调。
public void onFirstRemoteVideoDecoded(final int uid, int width, int height, int elapsed) {
runOnUiThread(() -> setupRemoteVideo(uid));
}
@Override//远端用户(通信模式)/主播(直播模式)离开当前频道回调。
public void onUserOffline(int uid, int reason) {
runOnUiThread(() -> onRemoteUserLeft());
}
@Override//远端用户静音回调。
public void onUserMuteVideo(final int uid, final boolean muted) {
runOnUiThread(() -> onRemoteUserVideoMuted(uid, muted));
}
};
/**
/**
/**
/**
/**