Files
MoGoAiCloudSdk/app/src/main/java/com/mogo/cloud/RealTimeActivity.java
2021-02-01 16:36:31 +08:00

79 lines
2.3 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.util.Log;
import android.widget.Button;
import android.widget.TextView;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import com.mogo.cloud.passport.MoGoAiCloudClient;
import com.mogo.realtime.Interface.MoGoAiCloudRealTime;
import com.mogo.realtime.entity.MogoSnapshotSetData;
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;
private TextView mTextView;
private TextView mStopTextView;
@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();
});
mTextView = findViewById(R.id.upResult);
mStopTextView = findViewById(R.id.stopResult);
}
private void setConfig() {
MoGoAiCloudClient.getInstance().getAiCloudClientConfig().setIsUseExternalLocation(false);
}
public void stopRealTimeService() {
MoGoAiCloudRealTime.unRegisterOnMsgListener(this);
MoGoAiCloudRealTime.stopRealTime();
mStopTextView.setText("stopRealTimeService");
}
@Override
protected void onDestroy() {
super.onDestroy();
stopRealTimeService();
}
@Override
public void onMsgSend(long id) {
Log.i(TAG, "send msg id : " + id);
mTextView.setText("send msg id :"+String.valueOf(id));
}
@Override
public void onMsgReceived(MogoSnapshotSetData mogoSnapshotSetData) {
Log.i(TAG, "onMsgReceived " + mogoSnapshotSetData);
}
}