Shecare Android SaaS SDK 开发文档

demo地址

https://github.com/iKangtai/ShecareSdkDemo_Android

类定义

1.核心使用类 ShecareSdk

2.经期类 Period

开始和结束必须成对出现

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
public class Period {
private int period; //1表示经期开始,2表示经期结束, 0表示无效
private String time; //日期 yyyy-MM-dd
private int deleted; // 1表示删除,0表示未删除

public int getPeriod() {
return period;
}

public void setPeriod(int period) {
this.period = period;
}

public String getTime() {
return time;
}

public void setTime(String time) {
this.time = time;
}

public int getDeleted() {
return deleted;
}

public void setDeleted(int deleted) {
this.status = status;
}
}

3.温度类 Temperature

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
public class Temperature {
private String date; // 时间 yyyy-MM-dd HH:mm:ss
private double temp; // 体温 35.55
private int deleted; // 删除标记 1表示删除,0表示未删除

public Temperature() {
}

public Temperature(String date, double temp) {
this.date = date;
this.temp = temp;
}

public String getDate() {
return date;
}

public void setDate(String date) {
this.date = date;
}

public double getTemp() {
return temp;
}

public void setTemp(double temp) {
this.temp = temp;
}

public int getDeleted(){
return deleted;
}

public void setDeleted(int deleted){
this.deleted = deleted;
}
}

4.用户生理信息类 UserInfo

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
public class UserInfo {
private int cycleLength; //周期长度 default 28天
private int mensLength; //经期长度 default 5天

public int getCycleLength() {
return cycleLength;
}

public void setCycleLength(int cycleLength) {
this.cycleLength = cycleLength;
}

public int getMensLength() {
return mensLength;
}

public void setMensLength(int mensLength) {
this.mensLength = mensLength;
}
}

5.初始化历史生理数据类 UploadData

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
public class UploadData {
private String userId;//userId
private String macAddress; //蓝牙地址:初始化上传生理数据时为 AA:AA:AA:AA:AA:AA
private UserInfoBean userInfo; // 用户生理信息
private List<TempsBean> temps; // 体温
private List<PeriodsBean> periods; // 经期,开始和结束必须成对出现

public String getUserId() {
return userId;
}

public void setUserId(String userId) {
this.userId = userId;
}

public String getMacAddress() {
return macAddress;
}

public void setMacAddress(String macAddress) {
this.macAddress = macAddress;
}

public UserInfoBean getUserInfo() {
return userInfo;
}

public void setUserInfo(UserInfoBean userInfo) {
this.userInfo = userInfo;
}

public List<TempsBean> getTemps() {
return temps;
}

public void setTemps(List<TempsBean> temps) {
this.temps = temps;
}

public List<PeriodsBean> getPeriods() {
return periods;
}

public void setPeriods(List<PeriodsBean> periods) {
this.periods = periods;
}

public static class UserInfoBean {
private int cycleLength; //周期长度 default 28天
private int mensLength; //经期长度 default 5天

public int getCycleLength() {
return cycleLength;
}

public void setCycleLength(int cycleLength) {
this.cycleLength = cycleLength;
}

public int getMensLength() {
return mensLength;
}

public void setMensLength(int mensLength) {
this.mensLength = mensLength;
}
}

public static class TempsBean {
private String tempValue; // 体温 35.55 private String date;
private String tempTime; // 时间 yyyy-MM-dd HH:mm:ss
private int deleted; // deleted 1表示删除,0 表示未删除

public String getTempValue() {
return tempValue;
}

public void setTempValue(String tempValue) {
this.tempValue = tempValue;
}

public String getTempTime() {
return tempTime;
}

public void setTempTime(String tempTime) {
this.tempTime = tempTime;
}

public int getDeleted(){
return deleted;
}

public void setDeleted(int deleted){
this.deleted = deleted;
}
}

public static class PeriodsBean {
private int period; //1表示经期开始,0表示经期结束
private String time; //日期 yyyy-MM-dd
private int deleted; // 1表示删除,0表示未删除

public int getPeriod() {
return period;
}

public void setPeriod(int period) {
this.period = period;
}

public String getTime() {
return time;
}

public void setTime(String time) {
this.time = time;
}

public int getDeleted(){
return deleted;
}

public void setDeleted(int deleted){
this.deleted = deleted;
}
}
}

接口说明,具体使用按照demo实例

1.设置 SDK 运行方式(默认为true, true 表示测试环境,false 表示正式环境)

1
public static void setIsDebug(boolean debug);

2.初始化 Contex 、 AppId、 AppSecret,AppId 和 AppSecret 由孕橙提供

1
public static void init(Application context, String appId, String appSecret);

3.设置 UserId

1
public static void setUserId(String userId);

4.上传集成 ShecareSDK 之前本地已有的经期和体温数据;

SDK 首次加载时,需要把用户的历史数据(包括经期、体温等)一次性传入,用于算法计算。后续有新数据时,只需要传人新数据即可。

1
public static void initUploadData(OnCallUpload onCallUpload);

5.获取曲线 url

1
public static String getCurveUrl();

6.获取智能分析结果

1
public static void getAnalysis(OnCallBack<AnalysisResp> onCallBack);

智能分析结果说明:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
{
"code": 0,
"message": null,
"data": {
"listAll": [
{
"list": [
{
"state": "normal",
"msg": "测温时间不规律,大部分在10点和11之间。",
"guanjian": null,
"url": null
},
{
"state": "bigwave",
"msg": "到目前体温测量一切正常,加油哦!",
"guanjian": null,
"url": null
},
{
"state": "pregnant",
"msg": "根据基础体温,确定排卵日为2018年3月1日。",
"guanjian": null,
"url": null
},
{
"state": "noyellow",
"msg": "黄体升温幅度较低,速度较慢,疑似黄体功能不足。",
"guanjian": null,
"url": null
}
],
"nowdate": "当前周期:2018年2月18日--今天"
},
{
"list": [
{
"state": "normal",
"msg": "测温时间不规律,大部分在10点和11之间。",
"guanjian": null,
"url": null
},
{
"state": "bigwave",
"msg": "到目前体温测量一切正常,加油哦!",
"guanjian": null,
"url": null
},
{
"state": "pregnant",
"msg": "根据基础体温,确定排卵日为2018年1月29日。",
"guanjian": null,
"url": null
},
{
"state": "noyellow",
"msg": "黄体升温幅度较低,速度较慢,疑似黄体功能不足。",
"guanjian": null,
"url": null
},
{
"state": "noyellow",
"msg": "本周期黄体期长度为18。长度过长,正常黄体其长度为10-16天。",
"guanjian": null,
"url": null
}
],
"nowdate": "历史周期:2018年1月1日--2018年2月17日"
},
{
"list": [
{
"state": "normal",
"msg": "本周期无有效的基础体温。",
"guanjian": null,
"url": null
}
],
"nowdate": "历史周期:2017年11月17日--2017年12月31日"
},
{
"list": [
{
"state": "normal",
"msg": "本周期无有效的基础体温。",
"guanjian": null,
"url": null
}
],
"nowdate": "历史周期:2017年10月1日--2017年11月16日"
},
{
"list": [
{
"state": "normal",
"msg": "周期长度最长48天,最短45天,平均周期长度47,周期长度稳定!",
"guanjian": null,
"url": null
},
{
"state": "normal",
"msg": "经期长度最长6天,最短3天,平均经期长度4,经期长度稳定。",
"guanjian": null,
"url": null
}
],
"nowdate": "整体周期分析:"
}
]
}
}

备注:当 code 非0时,说明内部分析出错,此时会在 message 中返回错误信息; listall 中的数据主要用到了:nowdate 和 message,nowdate 表示该段数据所处的周期, message 表示对这段周期分析的结果。

7.上传体温

1
public static void uploadTemps(List<Temperature> temps, OnCallBack<UploadDataResp> onCallBack)

8.上传经期

1
public static void uploadPeriods(List<Period> periods, OnCallBack<UploadDataResp> onCallBack)

9.上传生理信息

1
public static void uploadUserInfo(UserInfo userInfo, OnCallBack<UploadDataResp> onCallBack)

10.绑定设备

1
public static void bindDevice();

11.解绑设备

1
public static void unBindDevice(String macAddress, OnBindListener listener);

12.连接状态

1
public static boolean getConnectStatus();

13.获取设备测量数据

1
public static void setOnDeviceDataListener(OnReceiveDataListener listener);