| | |
| | | package com.hdl.hdlsdk; |
| | | |
| | | import android.Manifest; |
| | | import android.content.Context; |
| | | import android.content.Intent; |
| | | import android.content.pm.PackageInfo; |
| | | import android.content.pm.PackageManager; |
| | | import android.os.Build; |
| | | import android.os.Bundle; |
| | | import android.text.TextUtils; |
| | |
| | | import com.hdl.sdk.connect.bean.request.ListUploadRequest; |
| | | import com.hdl.sdk.connect.bean.response.BaseLocalResponse; |
| | | import com.hdl.sdk.connect.bean.response.GatewaySearchBean; |
| | | import com.hdl.sdk.connect.bean.response.UpdateInfo; |
| | | import com.hdl.sdk.connect.callback.HDLLinkCallBack; |
| | | import com.hdl.sdk.connect.callback.HDLLinkResponseCallBack; |
| | | import com.hdl.sdk.connect.cloud.CallBackListener; |
| | | import com.hdl.sdk.connect.cloud.CheckAppVersionListener; |
| | | import com.hdl.sdk.connect.cloud.HDLException; |
| | | import com.hdl.sdk.connect.config.HDLLinkConfig; |
| | | import com.hdl.sdk.connect.socket.HDLAuthSocket; |
| | |
| | | tv.setText("申请成功"); |
| | | responseTv.setText(msg.toString()); |
| | | secret = msg.toString(); |
| | | } |
| | | }); |
| | | |
| | | } |
| | | |
| | | void checkAppVersion() { |
| | | tv.setText("开始检测更新..."); |
| | | responseTv.setText(""); |
| | | |
| | | // //正式服务器 |
| | | String appKey = "i8hR07jzrIS";//appkey |
| | | String appSecret = "BmnJ8RWTtaVEBk24zPPF4UMwfYu0lAWU";//appsecret |
| | | |
| | | String appCode = "1697150870315999233";//appCode |
| | | |
| | | HDLLink.getInstance().checkAppVersion(this, appKey, appSecret, getAppVersionName(this), appCode, new CheckAppVersionListener() { |
| | | @Override |
| | | public void onSuccess(UpdateInfo info) { |
| | | tv.setText("有新更新"); |
| | | responseTv.setText(info.toString()); |
| | | } |
| | | |
| | | @Override |
| | | public void onError(HDLException e) { |
| | | tv.setText("检测更新失败"); |
| | | responseTv.setText(e.getMsg()); |
| | | } |
| | | }); |
| | | |
| | |
| | | beans.add(new DemoBean("UDP发送,监听主题回复,带重发带回调")); |
| | | beans.add(new DemoBean("TCP发送,监听主题回复,带重发带回调")); |
| | | beans.add(new DemoBean("退网")); |
| | | beans.add(new DemoBean("检测更新")); |
| | | demoAdapter = new DemoAdapter(beans); |
| | | rv.setAdapter(demoAdapter); |
| | | |
| | |
| | | case 15: |
| | | //退网 |
| | | deleteNetwork(); |
| | | break; |
| | | case 16: |
| | | //检测更新 |
| | | checkAppVersion(); |
| | | break; |
| | | } |
| | | } |
| | |
| | | } |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * 获取APP版本 |
| | | * |
| | | * @param context |
| | | * @return |
| | | */ |
| | | public static String getAppVersionName(Context context) { |
| | | String versionName = "0"; |
| | | try { |
| | | PackageManager packageManager = context.getPackageManager(); |
| | | PackageInfo packageInfo = packageManager.getPackageInfo(context.getPackageName(), 0); |
| | | versionName = packageInfo.versionName; |
| | | if (TextUtils.isEmpty(versionName)) { |
| | | versionName = "0"; |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return versionName; |
| | | } |
| | | |
| | | } |