溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

怎么在Android中利用agora實現(xiàn)一個視頻會議功能

發(fā)布時間:2021-01-29 14:56:24 來源:億速云 閱讀:226 作者:Leah 欄目:開發(fā)技術(shù)

這篇文章將為大家詳細(xì)講解有關(guān)怎么在Android中利用agora實現(xiàn)一個視頻會議功能,文章內(nèi)容質(zhì)量較高,因此小編分享給大家做個參考,希望大家閱讀完這篇文章后對相關(guān)知識有一定的了解。

代碼

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;
 }
}

關(guān)于怎么在Android中利用agora實現(xiàn)一個視頻會議功能就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,可以學(xué)到更多知識。如果覺得文章不錯,可以把它分享出去讓更多的人看到。

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI