|
@@ -45,9 +45,12 @@ import com.naz.sdkdemo.base.BaseActivity;
|
|
|
import com.naz.sdkdemo.bean.PrintModule;
|
|
|
import com.naz.sdkdemo.bean.PrintModule2;
|
|
|
import com.naz.sdkdemo.bean.PrintModule3;
|
|
|
+import com.naz.sdkdemo.comm.Constants;
|
|
|
import com.naz.sdkdemo.helper.SerialPortManager;
|
|
|
import com.naz.sdkdemo.http.ApiHelper;
|
|
|
import com.naz.sdkdemo.utils.MyTools;
|
|
|
+import com.naz.sdkdemo.utils.SPUtils;
|
|
|
+import com.naz.sdkdemo.utils.SerialUtil;
|
|
|
import com.naz.sdkdemo.weight.UserCache;
|
|
|
//import com.tencent.smtt.export.external.interfaces.WebResourceError;
|
|
|
//import com.tencent.smtt.export.external.interfaces.WebResourceRequest;
|
|
@@ -66,7 +69,10 @@ import java.io.UnsupportedEncodingException;
|
|
|
import java.lang.reflect.Method;
|
|
|
import java.lang.reflect.Type;
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
+import java.util.Objects;
|
|
|
import java.util.concurrent.ExecutorService;
|
|
|
import java.util.concurrent.Executors;
|
|
|
|
|
@@ -84,6 +90,8 @@ import androidx.lifecycle.LifecycleOwner;
|
|
|
import static net.posprinter.TSPLConst.FNT_SIMPLIFIED_CHINESE;
|
|
|
import static net.posprinter.TSPLConst.ROTATION_90;
|
|
|
|
|
|
+import android_serialport_api.SerialPortFinder;
|
|
|
+
|
|
|
public class MainActivity extends BaseActivity {
|
|
|
private final String TAG = "HomeActivity";
|
|
|
|
|
@@ -359,6 +367,15 @@ public class MainActivity extends BaseActivity {
|
|
|
}
|
|
|
|
|
|
@JavascriptInterface
|
|
|
+ public void getAllPort() {
|
|
|
+ // 遍历串口
|
|
|
+ SerialPortFinder finder = new SerialPortFinder();
|
|
|
+ String[] allDevicesPath = finder.getAllDevicesPath();
|
|
|
+ // 将结果返回给web页面
|
|
|
+ mWebView.loadUrl("javascript:getAllPort('" + Arrays.toString(allDevicesPath) + "')");
|
|
|
+ }
|
|
|
+
|
|
|
+ @JavascriptInterface
|
|
|
public void refreshData() {
|
|
|
Log.e(TAG, "clearCache");
|
|
|
mWebView.clearCache(false);
|