Android 基于agora 開發(fā)視頻會(huì)議的代碼
一、概述
參照官方demo,基于agora開發(fā),輸入會(huì)議號(hào)(頻道)和顯示名稱 參會(huì),可設(shè)置參會(huì)選項(xiàng)。
支持用戶注冊(cè)和登錄。
支持多人參會(huì)。
二、效果




三、代碼
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("請(qǐng)輸入會(huì)議號(hào)!");
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;
}
}
到此這篇關(guān)于Android 基于agora 開發(fā)視頻會(huì)議的文章就介紹到這了,更多相關(guān)Android開發(fā)視頻會(huì)議內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
Android自定義View實(shí)現(xiàn)QQ音樂中圓形旋轉(zhuǎn)碟子
這篇文章主要為大家詳細(xì)介紹了Android自定義View實(shí)現(xiàn)QQ音樂中圓形旋轉(zhuǎn)碟子,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2016-09-09
Android中CountDownTimer 實(shí)現(xiàn)倒計(jì)時(shí)功能
本篇文章主要介紹了Android中CountDownTimer 實(shí)現(xiàn)倒計(jì)時(shí)功能,CountDownTimer 是android 自帶的一個(gè)倒計(jì)時(shí)類,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-05-05
Android RxJava異步數(shù)據(jù)處理庫使用詳解
RxJava是一種異步數(shù)據(jù)處理庫,也是一種擴(kuò)展的觀察者模式。對(duì)于Android開發(fā)者來說,使用RxJava時(shí)也會(huì)搭配RxAndroid,它是RxJava針對(duì)Android平臺(tái)的一個(gè)擴(kuò)展,用于Android 開發(fā),它提供了響應(yīng)式擴(kuò)展組件,使用RxAndroid的調(diào)度器可以解決Android多線程問題2022-11-11
利用Jetpack Compose實(shí)現(xiàn)主題切換功能
這篇文章主要介紹了如何利用Android中的Jetpack Compose實(shí)現(xiàn)主題切換功能,文中的示例代碼講解詳細(xì),對(duì)我們學(xué)習(xí)有一定幫助,需要的可以參考一下2022-01-01
詳解Android使用Html.fromHtml需要注意的地方
本篇文章主要介紹了詳解Android使用Html.fromHtml需要注意的地方,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-07-07
Android自定義一個(gè)view?ViewRootImpl繪制流程示例
這篇文章主要為大家介紹了Android自定義一個(gè)view?ViewRootImpl繪制流程示例,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-09-09
Android單元測(cè)試之對(duì)Activity的測(cè)試示例
本篇文章主要介紹了Android單元測(cè)試之對(duì)Activity的測(cè)試示例,具有一定的參考價(jià)值,有興趣的可以了解一下2017-08-08

