写在前面
母亲的眼神越来越不好了,长期干农活的手也愈加粗糙,智能手机本是一个平常之物,她确无缘使用,现在仍在不断更换着“翻盖手机”。为了能让她绕开微信视频聊天那些繁琐而容易点错的功能,程序员的我“开发”下面一个聊天软件。
技术探索
本来一开始是准备直接0基础开始写代码的,转了一圈发现难度太大,又想到直接找现成的解决方案,结果下载了一堆app,都是各种广告弹窗,最后发现zego的一些开眼sdk基本可以满足,就花了一天时间进行“改造”。
主要改造的方向是:
(1)去掉app上的各种账号设置
(2)从首页直接进入聊天页面,不需要加好友啥的复杂功能
(3)字体字号足够大
最后
经过一天的改造,已经基本完成所需要的核心功能,但是还有许多问题
(1)聊天无法直接通过app拉起,需要两人同时上线才可以
(2)同时只能我和妈妈两个人聊天
(3)聊天的主画面是反的(本人是大窗显示,对方是小窗显示)
(4)挂断电话是app无法直接退出。
代码
这里我把核心代码写出来,如有大神可以帮忙完善我的1.0版本
MainAdapter.java
package im.zego.expresssample.adapter;import androidx.recyclerview.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import android.widget.TextView;import im.zego.expresssample.R;
import im.zego.expresssample.entity.ModuleInfo;import java.util.ArrayList;
import java.util.List;/*** Created by zego on 2018/2/6.*/public class MainAdapter extends RecyclerView.Adapter {private List<ModuleInfo> topicList = new ArrayList<>();private OnItemClickListener mOnItemClickListener;@Overridepublic RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.module_list, parent, false);return new MyViewHolder(v);}@Overridepublic void onBindViewHolder(final RecyclerView.ViewHolder holder, int position) {final MyViewHolder myViewHolder = (MyViewHolder) holder;if (mOnItemClickListener != null) {myViewHolder.list.setOnClickListener(v -> {if (mOnItemClickListener != null) {int position1 = myViewHolder.getLayoutPosition();v.setTag(topicList.get(position1));mOnItemClickListener.onItemClick(v, position1);}});}ModuleInfo moduleInfo = topicList.get(position);if (moduleInfo.getTitleName() != null) {myViewHolder.title.setVisibility(View.VISIBLE);} else {myViewHolder.title.setVisibility(View.GONE);}myViewHolder.name.setText(moduleInfo.getModule());}@Overridepublic int getItemCount() {return topicList.size();}/*** 新增模块信息** @param moduleInfo module info*/public void addModuleInfo(ModuleInfo moduleInfo) {topicList.add(moduleInfo);notifyDataSetChanged();}public void clear() {topicList.clear();}public static class MyViewHolder extends RecyclerView.ViewHolder {RelativeLayout list;TextView name;RelativeLayout title;MyViewHolder(View itemView) {super(itemView);list = itemView.findViewById(R.id.list);name = itemView.findViewById(R.id.name);title = itemView.findViewById(R.id.title);}}public void setOnItemClickListener(OnItemClickListener mOnItemClickListener) {this.mOnItemClickListener = mOnItemClickListener;}public interface OnItemClickListener {void onItemClick(View view, int position);}
}
MainActivity.java
package im.zego.expresssample.ui;import android.content.Intent;
import android.content.pm.PackageManager;import android.os.Build;
import android.os.Bundle;import androidx.core.content.ContextCompat;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.DefaultItemAnimator;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;import im.zego.debugandconfig.SettingActivity;
import im.zego.others.camera.CameraActivity;
import im.zego.others.effectsbeauty.EffectsBeautyActivity;
import im.zego.others.multivideosource.MultiVideoSourceActivity;
import im.zego.others.screensharing.ScreenSharingActivity;
import im.zego.others.beautyandwatermarkandsnapshot.BeautyWatermarkSnapshotActivity;
import im.zego.others.flowcontrol.FlowControlActivity;
import im.zego.others.mediaplayer.UI.MediaPlayerSelectionActivity;
import im.zego.others.multiplerooms.MultipleRoomsActivity;
import im.zego.others.networkandperformance.NetworkAndPerformanceActivity;
import im.zego.others.recording.RecordingActivity;
import im.zego.others.security.SecurityActivity;
import im.zego.others.sei.SEIActivity;
import im.zego.others.streammixing.MixerMainActivity;
import im.zego.others.superresolution.SuperResolutionActivity;import im.zego.CustomerVideoCapture.CustomerVideoCaptureActivity;
import im.zego.Scenes.VideoForMultipleUsers.VideoForMultipleUsersLogin;
import im.zego.advancedaudioprocessing.audio3a.Audio3aActivity;
import im.zego.advancedaudioprocessing.audioeffectplayer.AudioEffectPlayerActivity;
import im.zego.advancedaudioprocessing.customaudiocaptureandrendering.CustomAudioCaptureAndRenderingLoginActivity;
import im.zego.advancedaudioprocessing.earreturnandchannelsettings.EarReturnandChannelSettingsActivity;
import im.zego.advancedaudioprocessing.originalaudiodataacquisition.OriginalAudioDataAcquisitionActivity;
import im.zego.advancedaudioprocessing.rangeaudio.ui.RangeAudioActivity;
import im.zego.advancedaudioprocessing.soundlevelandspectrum.ui.SoundLevelAndSpectrumMainActivity;
import im.zego.advancedaudioprocessing.voicechange.VoiceChangeActivity;
import im.zego.encodinganddecoding.EncodingAndDecoding;
import im.zego.advancedstreaming.h265.H265LoginActivity;
import im.zego.advancedstreaming.lowlatencylive.LowLatencyLive;
import im.zego.quickstart.commonusage.CommonUsage;
import im.zego.quickstart.playing.Playing;
import im.zego.quickstart.publishing.Publishing;
import im.zego.quickstart.videochat.VideoChat;
import im.zego.quickstart.videochat.VideoChatLogin;
import im.zego.commonfeatures.roommessage.RoomMessageActivity;
import im.zego.advancedstreaming.streamByCdn.StreamByCdn;
import im.zego.advancedstreaming.streammonitoring.StreamMonitoring;
import im.zego.commonfeatures.commonvideoconfig.CommonVideoConfigActivity;
import im.zego.advancedstreaming.publishingmultiplestreams.ui.PublishingMultipleStreams;import im.zego.customrender.ui.ZGVideoRenderTypeUI;
import im.zego.expresssample.R;
import im.zego.expresssample.adapter.MainAdapter;
import im.zego.expresssample.entity.ModuleInfo;
import im.zego.commonfeatures.videorotation.VideoRotationSelectionActivity;
import im.zego.others.videoobjectsegmentation.VideoObjectSegmentationLoginActivity;
import com.tencent.bugly.crashreport.CrashReport;public class MainActivity extends AppCompatActivity {private MainAdapter mainAdapter = new MainAdapter();private static final int REQUEST_PERMISSION_CODE = 101;private RecyclerView moduleList;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);CrashReport.initCrashReport(getApplicationContext(), "13a8646a49", false);if (!isTaskRoot()) {/* If this is not the root activity */Intent intent = getIntent();String action = intent.getAction();if (intent.hasCategory(Intent.CATEGORY_LAUNCHER) && Intent.ACTION_MAIN.equals(action)) {finish();return;}}moduleList = findViewById(R.id.module_list);mainAdapter.setOnItemClickListener((view, position) -> {boolean orRequestPermission = this.checkOrRequestPermission(REQUEST_PERMISSION_CODE);ModuleInfo moduleInfo = (ModuleInfo) view.getTag();if (orRequestPermission) {String module = moduleInfo.getModule();if (module.equals(getString(R.string.custom_video_rendering))){ZGVideoRenderTypeUI.actionStart(MainActivity.this);}else if(module.equals(getString(R.string.common_video_config))){CommonVideoConfigActivity.actionStart(MainActivity.this);}else if(module.equals(getString(R.string.video_for_multiple_users))){VideoForMultipleUsersLogin.actionStart(MainActivity.this);}else if(module.equals(getString(R.string.video_rotation))){VideoRotationSelectionActivity.actionStart(MainActivity.this);}else if(module.equals(getString(R.string.beautify_watermark_snapshot))){BeautyWatermarkSnapshotActivity.actionStart(MainActivity.this);}else if (module.equals(getString(R.string.stream_monitoring))){StreamMonitoring.actionStart(MainActivity.this);}else if (module.equals(getString(R.string.publishing_multiple_streams))){PublishingMultipleStreams.actionStart(MainActivity.this);}else if (module.equals(getString(R.string.stream_by_cdn))){StreamByCdn.actionStart(MainActivity.this);}else if (module.equals(getString(R.string.low_latency_live))){LowLatencyLive.actionStart(MainActivity.this);}else if (module.equals(getString(R.string.h265))){H265LoginActivity.actionStart(MainActivity.this);}else if (module.equals(getString(R.string.common_usage))){CommonUsage.actionStart(MainActivity.this);}else if (module.equals(getString(R.string.video_chat))){VideoChat.actionStart(MainActivity.this);}else if (module.equals(getString(R.string.publishing))){Publishing.actionStart(MainActivity.this);}else if (module.equals(getString(R.string.playing))){Playing.actionStart(MainActivity.this);}else if (module.equals(getString(R.string.room_message))){RoomMessageActivity.actionStart(MainActivity.this);}else if (module.equals(getString(R.string.encoding_decoding))){EncodingAndDecoding.actionStart(MainActivity.this);}else if (module.equals(getString(R.string.custom_video_capture))){CustomerVideoCaptureActivity.actionStart(MainActivity.this);}else if (module.equals(getString(R.string.log_version_debug))){SettingActivity.actionStart(MainActivity.this);}else if (module.equals(getString(R.string.stream_mixing))){MixerMainActivity.actionStart(MainActivity.this);}else if (module.equals(getString(R.string.recording))){RecordingActivity.actionStart(MainActivity.this);}else if (module.equals(getString(R.string.media_player))){MediaPlayerSelectionActivity.actionStart(MainActivity.this);} else if (module.equals(getString(R.string.camera))) {CameraActivity.actionStart(MainActivity.this);} else if (module.equals(getString(R.string.multiple_rooms))){MultipleRoomsActivity.actionStart(MainActivity.this);}else if (module.equals(getString(R.string.flow_control))){FlowControlActivity.actionStart(MainActivity.this);}else if (module.equals(getString(R.string.network_and_performance))){NetworkAndPerformanceActivity.actionStart(MainActivity.this);}else if (module.equals(getString(R.string.security))) {SecurityActivity.actionStart(MainActivity.this);}else if (module.equals(getString(R.string.screen_sharing))) {ScreenSharingActivity.actionStart(MainActivity.this);}else if (module.equals(getString(R.string.sei))){SEIActivity.actionStart(MainActivity.this);}else if (module.equals(getString(R.string.voice_change_reverb_stereo))){VoiceChangeActivity.actionStart(MainActivity.this);}}});// UI SettingmoduleList.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));moduleList.setAdapter(mainAdapter);moduleList.setItemAnimator(new DefaultItemAnimator());// Add Module
// mainAdapter.addModuleInfo(new ModuleInfo().moduleName(getString(R.string.common_usage)).titleName(getString(R.string.quick_start)));mainAdapter.addModuleInfo(new ModuleInfo().moduleName(getString(R.string.video_chat)));
// mainAdapter.addModuleInfo(new ModuleInfo().moduleName(getString(R.string.publishing)));
// mainAdapter.addModuleInfo(new ModuleInfo().moduleName(getString(R.string.playing)));
// mainAdapter.addModuleInfo(new ModuleInfo().moduleName(getString(R.string.video_for_multiple_users)).titleName(getString(R.string.scenes)));
// mainAdapter.addModuleInfo(new ModuleInfo().moduleName(getString(R.string.common_video_config)).titleName(getString(R.string.common_features)));
// mainAdapter.addModuleInfo(new ModuleInfo().moduleName(getString(R.string.video_rotation)));
// mainAdapter.addModuleInfo(new ModuleInfo().moduleName(getString(R.string.room_message)));
// mainAdapter.addModuleInfo(new ModuleInfo().moduleName(getString(R.string.stream_monitoring)).titleName(getString(R.string.advanced_streaming)));
// mainAdapter.addModuleInfo(new ModuleInfo().moduleName(getString(R.string.publishing_multiple_streams)));
// mainAdapter.addModuleInfo(new ModuleInfo().moduleName(getString(R.string.stream_by_cdn)));
mainAdapter.addModuleInfo(new ModuleInfo().moduleName(getString(R.string.low_latency_live)));
// mainAdapter.addModuleInfo(new ModuleInfo().moduleName(getString(R.string.h265)));
// mainAdapter.addModuleInfo(new ModuleInfo().moduleName(getString(R.string.encoding_decoding)).titleName(getString(R.string.advanced_video_processing)));
// mainAdapter.addModuleInfo(new ModuleInfo().moduleName(getString(R.string.custom_video_rendering)));
// mainAdapter.addModuleInfo(new ModuleInfo().moduleName(getString(R.string.custom_video_capture)));
// mainAdapter.addModuleInfo(new ModuleInfo().moduleName(getString(R.string.voice_change_reverb_stereo)).titleName(getString(R.string.advanced_audio_processing)));
// mainAdapter.addModuleInfo(new ModuleInfo().moduleName(getString(R.string.ear_return_and_channel_settings)));
// mainAdapter.addModuleInfo(new ModuleInfo().moduleName(getString(R.string.soundlevel_and_audioSpectrum)));
// mainAdapter.addModuleInfo(new ModuleInfo().moduleName(getString(R.string.aec_ans_agc)));
// mainAdapter.addModuleInfo(new ModuleInfo().moduleName(getString(R.string.audio_effect_player)));
// mainAdapter.addModuleInfo(new ModuleInfo().moduleName(getString(R.string.original_audio_data_acquisition)));
// mainAdapter.addModuleInfo(new ModuleInfo().moduleName(getString(R.string.custom_audio_capture_and_rendering)));
// mainAdapter.addModuleInfo(new ModuleInfo().moduleName(getString(R.string.range_audio)));
// mainAdapter.addModuleInfo(new ModuleInfo().moduleName(getString(R.string.subject_segmentation)).titleName(getString(R.string.others)));
// mainAdapter.addModuleInfo(new ModuleInfo().moduleName(getString(R.string.super_resolution)));
// mainAdapter.addModuleInfo(new ModuleInfo().moduleName(getString(R.string.beautify_watermark_snapshot)));
// mainAdapter.addModuleInfo(new ModuleInfo().moduleName(getString(R.string.effects_beauty)));
// mainAdapter.addModuleInfo(new ModuleInfo().moduleName(getString(R.string.stream_mixing)));
// mainAdapter.addModuleInfo(new ModuleInfo().moduleName(getString(R.string.recording)));
// mainAdapter.addModuleInfo(new ModuleInfo().moduleName(getString(R.string.media_player)));
// mainAdapter.addModuleInfo(new ModuleInfo().moduleName(getString(R.string.camera)));
// mainAdapter.addModuleInfo(new ModuleInfo().moduleName(getString(R.string.multiple_rooms)));
// mainAdapter.addModuleInfo(new ModuleInfo().moduleName(getString(R.string.flow_control)));
// mainAdapter.addModuleInfo(new ModuleInfo().moduleName(getString(R.string.network_and_performance)));
// mainAdapter.addModuleInfo(new ModuleInfo().moduleName(getString(R.string.security)));
// mainAdapter.addModuleInfo(new ModuleInfo().moduleName(getString(R.string.screen_sharing)));
// mainAdapter.addModuleInfo(new ModuleInfo().moduleName(getString(R.string.sei)));
// mainAdapter.addModuleInfo(new ModuleInfo().moduleName(getString(R.string.multi_video_source)));
// mainAdapter.addModuleInfo(new ModuleInfo().moduleName(getString(R.string.log_version_debug)).titleName(getString(R.string.debug_config)));}// 需要申请 麦克风权限-读写sd卡权限-摄像头权限private static String[] PERMISSIONS_STORAGE = {"android.permission.CAMERA","android.permission.RECORD_AUDIO","android.permission.WRITE_EXTERNAL_STORAGE"};/*** 校验并请求权限*/public boolean checkOrRequestPermission(int code) {if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {if (ContextCompat.checkSelfPermission(this, "android.permission.CAMERA") != PackageManager.PERMISSION_GRANTED|| ContextCompat.checkSelfPermission(this, "android.permission.RECORD_AUDIO") != PackageManager.PERMISSION_GRANTED) {requestPermissions(PERMISSIONS_STORAGE, code);return false;}}return true;}
}
VideoChat
//本页为打电话的视频显示与对话页面
package im.zego.quickstart.videochat;import android.app.Activity;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Bundle;
import android.view.TextureView;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;import androidx.appcompat.app.AppCompatActivity;
import androidx.core.content.ContextCompat;import org.json.JSONObject;import java.util.ArrayList;import im.zego.commontools.logtools.AppLogger;
import im.zego.commontools.logtools.LogView;
import im.zego.commontools.logtools.logLinearLayout;
import im.zego.commontools.uitools.ZegoViewUtil;
import im.zego.keycenter.KeyCenter;
import im.zego.keycenter.UserIDHelper;
import im.zego.quickstart.R;
import im.zego.zegoexpress.ZegoExpressEngine;
import im.zego.zegoexpress.callback.IZegoApiCalledEventHandler;
import im.zego.zegoexpress.callback.IZegoEventHandler;
import im.zego.zegoexpress.constants.ZegoPlayerState;
import im.zego.zegoexpress.constants.ZegoPublisherState;
import im.zego.zegoexpress.constants.ZegoRoomState;
import im.zego.zegoexpress.constants.ZegoRoomStateChangedReason;
import im.zego.zegoexpress.constants.ZegoScenario;
import im.zego.zegoexpress.constants.ZegoUpdateType;
import im.zego.zegoexpress.entity.ZegoCanvas;
import im.zego.zegoexpress.entity.ZegoEngineProfile;
import im.zego.zegoexpress.entity.ZegoRoomConfig;
import im.zego.zegoexpress.entity.ZegoStream;
import im.zego.zegoexpress.entity.ZegoUser;public class VideoChat extends AppCompatActivity {TextureView previewView;TextureView minplayView;TextView roomIDTextView;TextView userIDTextView;TextView publishStreamIDTextView;Button stopButton;String roomID;String userID;String publishStreamID;String playStreamID;ZegoExpressEngine engine;ZegoPublisherState publisherState;ZegoPlayerState playerState;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_video_chat);requestPermission();bindView();getVideoChatConfig();setupView();setLogComponent();createEngine();setEventHandler();loginRoom();setStopButtonEvent();setApiCalledResult();}public static void actionStart(Activity activity) {String userID = UserIDHelper.getInstance().getUserID();Intent intent = new Intent(activity, VideoChat.class);intent.putExtra("roomID", "001");intent.putExtra("userID", userID);intent.putExtra("publishStreamID", "s_" + userID);activity.startActivity(intent);}// Request for permissionpublic void requestPermission() {String[] PERMISSIONS_STORAGE = {"android.permission.CAMERA","android.permission.RECORD_AUDIO"};if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {if (ContextCompat.checkSelfPermission(this, "android.permission.CAMERA") != PackageManager.PERMISSION_GRANTED|| ContextCompat.checkSelfPermission(this, "android.permission.RECORD_AUDIO") != PackageManager.PERMISSION_GRANTED) {requestPermissions(PERMISSIONS_STORAGE, 101);}}}@Overrideprotected void onDestroy() {// Destroy the engineZegoExpressEngine.destroyEngine(null);super.onDestroy();}public void bindView() {previewView = findViewById(R.id.previewView);minplayView = findViewById(R.id.minplayView);roomIDTextView = findViewById(R.id.roomIDTextView);userIDTextView = findViewById(R.id.userIDTextView);publishStreamIDTextView = findViewById(R.id.publishStreamIDTextView);stopButton = findViewById(R.id.stopButton);}public void getVideoChatConfig() {roomID = getIntent().getStringExtra("roomID");userID = getIntent().getStringExtra("userID");publishStreamID = getIntent().getStringExtra("publishStreamID");}public void setupView() {setTitle("视频通话");roomIDTextView.setText(String.format("roomID:%s", roomID));userIDTextView.setText(String.format("userID:%s", userID));publishStreamIDTextView.setText(String.format("publishStreamID:%s", publishStreamID));minplayView.setVisibility(View.INVISIBLE);}// Set log component. It includes a pop-up dialog.public void setLogComponent() {logLinearLayout logHiddenView = findViewById(R.id.logView);logHiddenView.setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View v) {LogView logview = new LogView(getApplicationContext());logview.show(getSupportFragmentManager(),null);}});}public void createEngine() {// Initialize ZegoExpressEngineAppLogger.getInstance().callApi("Create ZegoExpressEngine");ZegoEngineProfile profile = new ZegoEngineProfile();profile.appID = KeyCenter.getInstance().getAppID();profile.appSign = KeyCenter.getInstance().getAppSign();// Here we use the high quality video call scenario as an example,// you should choose the appropriate scenario according to your actual situation,// for the differences between scenarios and how to choose a suitable scenario,// please refer to https://docs.zegocloud.com/article/14940profile.scenario = ZegoScenario.HIGH_QUALITY_VIDEO_CALL;profile.application = getApplication();engine = ZegoExpressEngine.createEngine(profile, null);}public void setEventHandler() {engine.setEventHandler(new IZegoEventHandler() {@Overridepublic void onRoomStateChanged(String roomID, ZegoRoomStateChangedReason reason, int errorCode, JSONObject extendedData) {AppLogger.getInstance().receiveCallback("", roomID, reason.toString(), errorCode);if(reason == ZegoRoomStateChangedReason.LOGINED){startLive();}}@Overridepublic void onRoomStreamUpdate(String roomID, ZegoUpdateType updateType, ArrayList<ZegoStream> streamList, JSONObject extendedData) {super.onRoomStreamUpdate(roomID, updateType, streamList, extendedData);if (updateType == ZegoUpdateType.ADD) {// When the updateType is Add, stop playing current stream(if exist) and start playing new stream.if (playerState != ZegoPlayerState.NO_PLAY) {engine.stopPlayingStream(playStreamID);playStreamID = null;}// No processing, just play the first streamZegoStream stream = streamList.get(0);playStreamID = stream.streamID;ZegoCanvas playCanvas = new ZegoCanvas(minplayView);engine.startPlayingStream(playStreamID, playCanvas);} else {// When the updateType is Delete, if the stream is being played, stop playing the stream.if (playerState == ZegoPlayerState.NO_PLAY) {return;}for (ZegoStream stream : streamList) {if (playStreamID.equals(stream.streamID)) {engine.stopPlayingStream(playStreamID);playStreamID = null;}}}}@Overridepublic void onPublisherStateUpdate(String streamID, ZegoPublisherState state, int errorCode, JSONObject extendedData) {super.onPublisherStateUpdate(streamID, state, errorCode, extendedData);AppLogger.getInstance().receiveCallback("", state.value());publisherState = state;}@Overridepublic void onPlayerStateUpdate(String streamID, ZegoPlayerState state, int errorCode, JSONObject extendedData) {super.onPlayerStateUpdate(streamID, state, errorCode, extendedData);AppLogger.getInstance().receiveCallback("", state.value());playerState = state;if (playerState == ZegoPlayerState.PLAYING) {minplayView.setVisibility(View.VISIBLE);} else {minplayView.setVisibility(View.INVISIBLE);}}});}public void loginRoom() {// Login roomAppLogger.getInstance().callApi("Login Room, roomID:%s", roomID);engine.loginRoom(roomID, new ZegoUser(userID));}public void startLive() {// Start previewAppLogger.getInstance().callApi("Start preview");ZegoCanvas previewCanvas = new ZegoCanvas(previewView);engine.startPreview(previewCanvas);// Start publishAppLogger.getInstance().callApi("Start publishing stream. streamID:%s", publishStreamID);engine.startPublishingStream(publishStreamID);}public void setStopButtonEvent() {stopButton.setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View view) {// Destroy Activity,finish();}});}public void setApiCalledResult(){// Update log with api called resultsZegoExpressEngine.setApiCalledCallback(new IZegoApiCalledEventHandler() {@Overridepublic void onApiCalledResult(int errorCode, String funcName, String info) {super.onApiCalledResult(errorCode, funcName, info);if (errorCode == 0){AppLogger.getInstance().success("[%s]:%s", funcName, info);} else {AppLogger.getInstance().fail("[%d]%s:%s", errorCode, funcName, info);}}});}
}
参考:https://doc-zh.zego.im/article/3125