step1:

implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'com.google.android.material:material:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
//
implementation 'com.lzy.net:okgo:3.0.4'
implementation 'com.alibaba:fastjson:1.1.67.android'
implementation 'com.google.code.gson:gson:2.8.5'
// https://mvnrepository.com/artifact/org.apache.commons/commons-lang3
implementation 'org.apache.commons:commons-lang3:3.0'

step2:

<uses-permission android:name="android.permission.INTERNET" />

<application
android:name=".MyApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:networkSecurityConfig="@xml/network_security_config"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.OkGoDemoTwo">


<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<base-config cleartextTrafficPermitted="true">

<trust-anchors>
<certificates src="system" />
</trust-anchors>
</base-config>
</network-security-config>

step3: get

package com.example.okgodemotwo;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.util.Log;

import com.alibaba.fastjson.JSONObject;
import com.lzy.okgo.OkGo;



public class AddActivity extends AppCompatActivity {
private String url = "http://or/dc/loadProduct";



@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_test);
getData();
}

private void getData() {
OkGo.<String>get(url)
.params("userId", "minApp113043")
.params("equipmentId", "zcz002105405")
.params("productId", "zcz002")
.execute(new com.lzy.okgo.callback.StringCallback() {
@Override
public void onSuccess(com.lzy.okgo.model.Response<String> response) {
ShareReceiveBean mShareReceiveBean = JSONObject.parseObject(response.body(), ShareReceiveBean.class);
Log.e("TAG", "AddActivity_onSuccess:" + mShareReceiveBean);
}

@Override
public void onError(com.lzy.okgo.model.Response<String> response) {
super.onError(response);
Log.e("TAG", "onError:" + response);
}
});
}


}

step4: post

package com.example.okgodemotwo;


import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.util.Log;

import com.alibaba.fastjson.JSONObject;
import com.google.gson.Gson;
import com.lzy.okgo.OkGo;


public class AddDeviceDataActivity extends AppCompatActivity {
private String url = "http:c/operateDevices";

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_add_product);
getData();
}

private void getData() {
SendDeviceBean mSendDeviceBean = new SendDeviceBean();
mSendDeviceBean.setEquipmentId("zcz002105405");
mSendDeviceBean.setUserId("minApp113043");
mSendDeviceBean.setProductId("zcz002");
mSendDeviceBean.setEquipmentNote("一氧化碳3(co)");
mSendDeviceBean.setEquipmentRoom("洗手间");
mSendDeviceBean.setEquipmentLabel("");
mSendDeviceBean.setButNames("按键一");
mSendDeviceBean.setEquipmentType("WIFI");



Gson gson = new Gson();
String jsonString = gson.toJson(mSendDeviceBean);
OkGo.<String>post(url)
.upJson(jsonString)
.execute(new com.lzy.okgo.callback.StringCallback() {
@Override
public void onSuccess(com.lzy.okgo.model.Response<String> response) {
UpdateBean mUpdateBean = JSONObject.parseObject(response.body(), UpdateBean.class);
Log.e("TAG", "onSuccess:" + mUpdateBean);
}

@Override
public void onError(com.lzy.okgo.model.Response<String> response) {
super.onError(response);
Log.e("TAG", "onError:" + response);
}
});
}


}

step5: delete

package com.example.okgodemotwo;


import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.util.Log;

import com.alibaba.fastjson.JSONObject;
import com.google.gson.Gson;
import com.lzy.okgo.OkGo;


public class DeleteActivity extends AppCompatActivity {
String url = "httpdor/dc/deleteDevices";

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
getData();
}

private void getData() {
OkGo.<String>delete(url)
.params("deviceId", "zcz00110011")
.execute(new com.lzy.okgo.callback.StringCallback() {
@Override
public void onSuccess(com.lzy.okgo.model.Response<String> response) {
DeleteBean mDeleteBean = JSONObject.parseObject(response.body(), DeleteBean.class);
Log.e("TAG", "onSuccess:" + mDeleteBean);
}

@Override
public void onError(com.lzy.okgo.model.Response<String> response) {
super.onError(response);
Log.e("TAG", "onError:" + response);
}
});
}
}

step6: put

package com.example.okgodemotwo;


import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.util.Log;

import com.alibaba.fastjson.JSONObject;
import com.google.gson.Gson;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.request.base.Request;


public class PushAllReadActivity extends AppCompatActivity {
private String url = "hupdateAccountId";


@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_test);
getData();
}


private void getData() {
OkGo.<String>put(url)
.params("accountId", "minApp108881")
.params("read", "1")
.execute(new com.lzy.okgo.callback.StringCallback() {
@Override
public void onSuccess(com.lzy.okgo.model.Response<String> response) {
Log.e("TAG", "onSuccess:" + response.body());
}

@Override
public void onError(com.lzy.okgo.model.Response<String> response) {
super.onError(response);
Log.e("TAG", "onError:" + response);
}

@Override
public void onStart(Request<String, ? extends Request> request) {
super.onStart(request);
Log.e("TAG", "onStart:" + request);

}
});
}
}

/**
{"message":"操作成功","code":200}
* */