74 lines
2.2 KiB
Java
74 lines
2.2 KiB
Java
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);
|
||
}
|
||
}
|