plus.nativeUI.showWaiting("正在打印中...");
console.log('开始打印中...');
var Socket = plus.android.importClass("java.net.Socket");
var PrintWriter = plus.android.importClass("java.io.PrintWriter");
var BufferedWriter = plus.android.importClass("java.io.BufferedWriter");
var OutputStreamWriter = plus.android.importClass("java.io.OutputStreamWriter");
var BufferedReader = plus.android.importClass("java.io.BufferedReader");
var InputStreamReader = plus.android.importClass("java.io.InputStreamReader");
var StrictMode = plus.android.importClass("android.os.StrictMode");
var Build = plus.android.importClass("android.os.Build");
if (Build.VERSION.SDK_INT > 9){
var policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
}
try {
var socket = new Socket('192.168.2.135',80);
socket.setKeepAlive(true);
outputStream = socket.getOutputStream();
plus.android.importClass(outputStream);
outputStream.write(plus.android.invoke('我们都是中国人民!', 'getBytes', 'gbk'));
outputStream.flush();
socket.shutdownOutput();
plus.nativeUI.closeWaiting();
console.log('打印结束...');
} catch(e){
console.log(e)
mui.toast("网络连接超时,请重新连接!")
plus.nativeUI.closeWaiting();
}
打印机无任何反应,请问如何处理?
拖拉机司机 (作者)
解决了哈
2019-09-12 09:27
m***@gmail.com
回复 拖拉机司机: 怎么解决的?
2019-12-20 10:58