Android 基于agora 开发视频会议的代码
作者:苹果园dog 时间:2021-11-30 02:53:04
一、概述
参照官方demo,基于agora开发,输入会议号(频道)和显示名称 参会,可设置参会选项。
支持用户注册和登录。
支持多人参会。
二、效果
三、代码
package io.agora.openvcall.ui;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.Switch;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import io.agora.openvcall.R;
import io.agora.openvcall.model.ConstantApp;
import io.agora.openvcall.ui.mycode.common;
public class MainActivity extends BaseActivity {
private final static Logger log = LoggerFactory.getLogger(MainActivity.class);
private String username;
private String password;
private String name;
private int user_id;
private String show_name;
private boolean videomute;
private boolean audiomute;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ActionBar ab = getSupportActionBar();
if (ab != null) {
ab.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
ab.setCustomView(R.layout.ard_agora_actionbar);
}
initP();
}
private void initP(){
String show_name = common.getName();
if(!TextUtils.isEmpty(show_name)){
this.name=show_name;
this.show_name=show_name;
common.setName(show_name);
EditText et = findViewById(R.id.user_name);
et.setText(show_name);
}
String _username = common.getUsername();
if(!TextUtils.isEmpty(_username)){
username=_username;
}
String _password = common.getPassword();
if(!TextUtils.isEmpty(_password)){
password=_password;
}
user_id = common.getUser_id();
}
public void onBackPressed(View view) {
onBackPressed();
}
@Override
protected void initUIandEvent() {
EditText v_channel = (EditText) findViewById(R.id.channel_name);
v_channel.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
}
});
String lastChannelName = vSettings().mChannelName;
if (!TextUtils.isEmpty(lastChannelName)) {
v_channel.setText(lastChannelName);
v_channel.setSelection(lastChannelName.length());
}
}
@Override
protected void deInitUIandEvent() {
}
@Override
public boolean onCreateOptionsMenu(final Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.menu_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle presses on the action bar items
switch (item.getItemId()) {
case R.id.action_settings:
forwardToSettings();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
public void onClickJoin(View view) {
forwardToRoom();
}
public void forwardToRoom() {
EditText v_channel = (EditText) findViewById(R.id.channel_name);
String channel = v_channel.getText().toString();
if(TextUtils.isEmpty(channel)){
showLongToast("请输入会议号!");
return;
}
vSettings().mChannelName = channel;
Intent i = new Intent(MainActivity.this, CallActivity.class);
i.putExtra(ConstantApp.ACTION_KEY_CHANNEL_NAME, channel);
//i.putExtra(ConstantApp.ACTION_KEY_ENCRYPTION_KEY, encryption);
i.putExtra(ConstantApp.ACTION_KEY_ENCRYPTION_MODE, getResources().getStringArray(R.array.encryption_mode_values)[vSettings().mEncryptionModeIndex]);
i.putExtra("username",username);
i.putExtra("password",password);
i.putExtra("name",name);
i.putExtra("user_id",user_id);
i.putExtra("videomute",videomute);
i.putExtra("audiomute",audiomute);
EditText show_name_E = (EditText) findViewById(R.id.user_name);
String _show_name = show_name_E.getText().toString();
i.putExtra("show_name",_show_name);
startActivity(i);
finish();
}
public void forwardToSettings() {
Intent i = new Intent(this, io.agora.openvcall.ui.SettingsActivity.class);
startActivity(i);
}
@Override
public void permissionGranted() {
}
public void onSwitch_audio(View view) {
boolean isChecked = ((Switch) view).isChecked();
this.audiomute=!isChecked;
}
public void onSwitch_video(View view) {
boolean isChecked = ((Switch) view).isChecked();
this.videomute=!isChecked;
}
}
来源:https://blog.csdn.net/u014556081/article/details/113178268
标签:Android,agora,视频会议
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
解决异常FileNotFoundException:class path resource找不到资源文件的问题
2021-12-26 18:24:14
![](https://img.aspxhome.com/file/2023/6/71676_0s.png)
android 照相功能的简单实例
2023-08-08 01:11:55
c#保存窗口位置大小操作类(序列化和文件读写功能)
2023-07-15 18:51:06
巧用Dictionary实现日志数据批量插入
2022-03-10 12:31:05
Kotlin中的惰性操作容器Sequence序列使用原理详解
2023-10-01 14:21:55
![](https://img.aspxhome.com/file/2023/7/84717_0s.jpg)
Java数据结构之树和二叉树的相关资料
2022-07-31 04:48:18
![](https://img.aspxhome.com/file/2023/4/110664_0s.png)
Android编程之ListView和EditText发布帖子隐藏软键盘功能详解
2023-11-06 23:09:55
Spring的Aware接口实现及执行顺序详解
2023-03-09 09:50:53
![](https://img.aspxhome.com/file/2023/6/71646_0s.png)
java 动态增加定时任务示例
2023-07-29 06:56:00
Java并发编程之浅谈ReentrantLock
2022-08-25 10:46:02
![](https://img.aspxhome.com/file/2023/5/91735_0s.png)
java实现微信点餐申请微信退款
2022-10-29 19:07:57
![](https://img.aspxhome.com/file/2023/5/75025_0s.jpg)
使用Spring自定义注解实现任务路由的方法
2023-12-20 22:34:11
Spring2.5.6开发环境搭建图文教程
2023-07-28 18:01:02
![](https://img.aspxhome.com/file/2023/4/74764_0s.jpg)
Springboot项目全局异常统一处理案例代码
2021-08-26 10:51:19
Springboot使用POI实现导出Excel文件示例
2021-09-22 08:18:31
![](https://img.aspxhome.com/file/2023/8/61398_0s.jpg)
Java线程安全解决方案(synchronized,ReentrantLock,Atomic)
2022-06-13 12:51:09
Java MapStruct解了对象映射的毒
2022-08-20 11:37:12
![](https://img.aspxhome.com/file/2023/5/86865_0s.png)
Java 开启多线程常见的4种方法
2023-11-23 02:30:10
![](https://img.aspxhome.com/file/2023/0/58580_0s.png)
android 中 webview 怎么用 localStorage
2023-04-28 04:38:36
Java实现石头剪刀布小游戏
2023-02-25 22:41:29
![](https://img.aspxhome.com/file/2023/2/75802_0s.jpg)