package com.mogo.cloud; import android.os.Bundle; import android.widget.Button; import androidx.annotation.Nullable; import androidx.appcompat.app.AppCompatActivity; import com.elegant.analytics.utils.Logger; import com.mogo.cloud.passport.MoGoAiCloudClientConfig; import com.mogo.cloud.socket.entity.SocketDownData; import com.mogo.realtime.api.MoGoAiCloudRealTime; import com.mogo.realtime.socket.IMogoCloudOnMsgListener; /** * @author liujing * @description 描述 * @since: 2021/1/21 */ public class RealTimeActivity extends AppCompatActivity implements IMogoCloudOnMsgListener { private static final String TAG = "RealTimeActivity"; private Button snapshotStartButton; private Button snapshotStopButton; @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_real_time); setConfig(); snapshotStartButton = findViewById(R.id.snapshotStart); snapshotStartButton.setOnClickListener(view -> { MoGoAiCloudRealTime.startRealTime(this, MoGoAiCloudClientConfig.getInstance().getServiceAppId()); MoGoAiCloudRealTime.registerOnMsgListener(this); }); snapshotStopButton = findViewById(R.id.snapshotStop); snapshotStopButton.setOnClickListener(view -> { stopRealTimeService(); }); } /** * 配置是否使用开发者提供的定位进行坐标上传 * true:开发者提供定位点坐标上传 * false:使用SDK内部定位点坐标上传 */ private void setConfig() { // MoGoAiCloudClient.getInstance().getAiCloudClientConfig().setIsUseExternalLocation(false); } public void stopRealTimeService() { MoGoAiCloudRealTime.unRegisterOnMsgListener(this); MoGoAiCloudRealTime.stopRealTime(); } @Override protected void onDestroy() { super.onDestroy(); stopRealTimeService(); } @Override public void onMsgSend(long id) { Logger.i(TAG, "send msg id : " + id); } @Override public void onMsgReceived(SocketDownData.LauncherSnapshotProto mogoSnapshotSetData) { } }