|
本帖最后由 czdh 于 2018-6-11 11:35 编辑
在app打包的时候失败了,打包到时候提示java文件里面一行代码错误,把这行代码注销后就可以打包成功了。但是程序已经在android studio中调通了。运行都很正常。
private BroadcastReceiver mReceiver;
Context mContext;
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
try {
if ("start".equals(action)){
registerReceiver();
callbackContext.success("ok");
return true;
}
if ("stop".equals(action)){
unRegisterReceiver();
callbackContext.success("stop");
return true;
}
if ("getScanStr".equals(action)){
JSONObject arg_object = args.getJSONObject(0);
mContext = cordova.getActivity().getApplicationContext();
mReceiver= new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
final String scanResult_1=intent.getStringExtra("SCAN_BARCODE1");
final String scanStatus=intent.getStringExtra("SCAN_STATE");
if("ok".equals(scanStatus)){
//成功
callbackContext.success(scanResult_1); //*****这行代码打包时提示错误,注销这行后打包成功。****
}else{
}
}
};
return true;
}
callbackContext.error("Invalid action");
return false;
} catch(Exception e) {
System.err.println("Exception: " + e.getMessage());
callbackContext.error(e.getMessage());
return false;
}
}
|
|