|
@@ -21,9 +21,11 @@ import com.alipay.arome.aromecli.AromeServiceInvoker;
|
|
|
import com.alipay.arome.aromecli.AromeServiceTask;
|
|
|
import com.alipay.arome.aromecli.requst.AromeActivateRequest;
|
|
|
import com.alipay.arome.aromecli.requst.AromeExitAppRequest;
|
|
|
+import com.alipay.arome.aromecli.requst.AromeGetAppStatusRequest;
|
|
|
import com.alipay.arome.aromecli.requst.AromeLaunchAppRequest;
|
|
|
import com.alipay.arome.aromecli.requst.AromeSendEventRequest;
|
|
|
import com.alipay.arome.aromecli.response.AromeExitAppResponse;
|
|
|
+import com.alipay.arome.aromecli.response.AromeGetAppStatusResponse;
|
|
|
import com.alipay.arome.aromecli.response.AromeResponse;
|
|
|
import com.alipay.iot.bpaas.api.BPaaSApi;
|
|
|
import com.alipay.iot.bpaas.api.BPaaSInitCallback;
|
|
@@ -1427,6 +1429,44 @@ public class MainActivity extends BaseHHActivity implements DeviceConfigContract
|
|
|
}
|
|
|
|
|
|
|
|
|
+
|
|
|
+ // 小程序状态
|
|
|
+ boolean appletRunnning;
|
|
|
+ boolean appleForeground;
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取小程序运行的状态
|
|
|
+ */
|
|
|
+ public void getAppletStatus(){
|
|
|
+
|
|
|
+ AromeGetAppStatusRequest request = new AromeGetAppStatusRequest();
|
|
|
+ request.appId = appletId;
|
|
|
+ AromeServiceInvoker.invoke(request, new AromeServiceTask.Callback<AromeGetAppStatusResponse>() {
|
|
|
+ @Override
|
|
|
+ public void onCallback(final AromeGetAppStatusResponse response) {
|
|
|
+
|
|
|
+ AppLogUtils.e("小程序运行状态response:"+response.toString());
|
|
|
+
|
|
|
+ if(response!=null){
|
|
|
+ // 小程序是否正在运行 true/false
|
|
|
+ Boolean isRunnning = response.isRunnning;
|
|
|
+ // 小程序是否在前台 true/false
|
|
|
+ Boolean isForeground = response.isForeground;
|
|
|
+
|
|
|
+
|
|
|
+ appletRunnning = isRunnning;
|
|
|
+ appleForeground = isForeground;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 日志统一打印
|
|
|
* 网络和本地保存日志
|
|
@@ -4048,11 +4088,22 @@ public class MainActivity extends BaseHHActivity implements DeviceConfigContract
|
|
|
|
|
|
final DeviceConfigResultBean newResultBean = resultBean;
|
|
|
|
|
|
+ // 先获取下小程序状态
|
|
|
+ getAppletStatus();
|
|
|
+
|
|
|
// 为了身份证初始化成功
|
|
|
mHandler.postDelayed(new Runnable() {
|
|
|
@Override
|
|
|
public void run() {
|
|
|
- initAndActive(newResultBean);
|
|
|
+
|
|
|
+ if(appletRunnning&&appleForeground){
|
|
|
+ // 小程序已经运行
|
|
|
+ AppLogUtils.e("小程序已经运行,不操作");
|
|
|
+ }else{
|
|
|
+ AppLogUtils.e("小程序没有运行,开始启动");
|
|
|
+ initAndActive(newResultBean);
|
|
|
+ }
|
|
|
+
|
|
|
// 如果未打开,那就是error1, no implement
|
|
|
}
|
|
|
}, 5 * 1000);
|