diff --git a/OpenLive-Android/app/src/main/java/io/agora/openlive/AgoraApplication.java b/OpenLive-Android/app/src/main/java/io/agora/openlive/AgoraApplication.java index 72f365f4..d010287a 100644 --- a/OpenLive-Android/app/src/main/java/io/agora/openlive/AgoraApplication.java +++ b/OpenLive-Android/app/src/main/java/io/agora/openlive/AgoraApplication.java @@ -21,11 +21,7 @@ public class AgoraApplication extends Application { public void onCreate() { super.onCreate(); try { - mRtcEngine = RtcEngine.create(getApplicationContext(), getString(R.string.private_app_id), mHandler); - // Sets the channel profile of the Agora RtcEngine. - // The Agora RtcEngine differentiates channel profiles and applies different optimization algorithms accordingly. For example, it prioritizes smoothness and low latency for a video call, and prioritizes video quality for a video broadcast. - mRtcEngine.setChannelProfile(io.agora.rtc.Constants.CHANNEL_PROFILE_LIVE_BROADCASTING); - mRtcEngine.enableVideo(); + mRtcEngine = RtcEngine.create(getApplicationContext(), getString(R.string.private_app_id), mHandler); mRtcEngine.setLogFile(FileUtil.initializeLogFile(this)); } catch (Exception e) { e.printStackTrace(); diff --git a/OpenLive-Android/app/src/main/java/io/agora/openlive/activities/LiveActivity.java b/OpenLive-Android/app/src/main/java/io/agora/openlive/activities/LiveActivity.java index 1769ac4c..94743cb5 100644 --- a/OpenLive-Android/app/src/main/java/io/agora/openlive/activities/LiveActivity.java +++ b/OpenLive-Android/app/src/main/java/io/agora/openlive/activities/LiveActivity.java @@ -44,7 +44,6 @@ private void initUI() { roomName.setSelected(true); initUserIcon(); - int role = getIntent().getIntExtra( io.agora.openlive.Constants.KEY_CLIENT_ROLE, Constants.CLIENT_ROLE_AUDIENCE); diff --git a/OpenLive-Android/app/src/main/java/io/agora/openlive/activities/RtcBaseActivity.java b/OpenLive-Android/app/src/main/java/io/agora/openlive/activities/RtcBaseActivity.java index 1c4bd31a..0406a441 100644 --- a/OpenLive-Android/app/src/main/java/io/agora/openlive/activities/RtcBaseActivity.java +++ b/OpenLive-Android/app/src/main/java/io/agora/openlive/activities/RtcBaseActivity.java @@ -16,8 +16,7 @@ public abstract class RtcBaseActivity extends BaseActivity implements EventHandl @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - registerRtcEventHandler(this); - configVideo(); + registerRtcEventHandler(this); joinChannel(); } @@ -42,6 +41,12 @@ private void joinChannel() { if (TextUtils.isEmpty(token) || TextUtils.equals(token, "#YOUR ACCESS TOKEN#")) { token = null; // default, no token } + + // Sets the channel profile of the Agora RtcEngine. + // The Agora RtcEngine differentiates channel profiles and applies different optimization algorithms accordingly. For example, it prioritizes smoothness and low latency for a video call, and prioritizes video quality for a video broadcast. + rtcEngine().setChannelProfile(io.agora.rtc.Constants.CHANNEL_PROFILE_LIVE_BROADCASTING); + rtcEngine().enableVideo(); + configVideo(); rtcEngine().joinChannel(token, config().getChannelName(), "", 0); }