Files
MoGoAiCloudSdk/app/src/main/java/com/mogo/cloud/RealTimeActivity.java
董宏宇 e30e9cab0e 发布新版本1.0.28-SNAPSHOT
修改utils包结构
2021-02-22 14:32:07 +08:00

74 lines
2.2 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package com.mogo.cloud;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.widget.Button;
import com.mogo.cloud.passport.MoGoAiCloudClient;
import com.mogo.realtime.api.MoGoAiCloudRealTime;
import com.mogo.realtime.entity.MogoSnapshotSetData;
import com.mogo.realtime.socket.IMogoCloudOnMsgListener;
import com.mogo.cloud.utils.logger.Logger;
/**
* @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, "com.mogo.launcher");
MoGoAiCloudRealTime.registerOnMsgListener(this);
});
snapshotStopButton = findViewById(R.id.snapshotStop);
snapshotStopButton.setOnClickListener(view -> {
stopRealTimeService();
});
}
/**
* 配置是否使用开发者提供的定位进行坐标上传
* true:开发者提供定位点坐标上传
* false:使用SDK内部定位点坐标上传
*/
private void setConfig() {
MoGoAiCloudClient.getInstance().getAiCloudClientConfig().setIsUseExternalLocation(true);
}
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(MogoSnapshotSetData mogoSnapshotSetData) {
Logger.i(TAG, "onMsgReceived " + mogoSnapshotSetData);
}
}