Closed liviso closed 5 years ago
Hi, I found this page: https://developer.zebra.com/docs/DOC-2101. It states that the version of DW on the CC5000 (Concierge) is DW 3.1.6. DataWedge setup information is here: http://techdocs.zebra.com/datawedge/6-8/guide/setup/. You may find it easier to launch the DataWedge application on the device and modify the parameters in Profile0 to see their effect
Yesterday I could turn off the scanner from scanner.disabled, but when it changes activity it turns on again, I need that in the other activity it stays off, I am checking in the documentation. Thanks
Interesting... which sdk are you using for scanner.disabled? I see an SDK documented at https://developer.zebra.com/docs/DOC-2008 but I have never used it. I strongly suspect the SDK will not inter-operate with DataWedge, either you would use the SDK or you would use DataWedge.
I'm using android 5.1, the datawedge version is 86.2.23 in a Device CC5000. I have configured the activities that I use from the emdk:
In the MainActivity when I recover the scanned upc I am turning off the scanner with this:
if(scanner==null && emdkManager!=null){ barcodeManager = (BarcodeManager)emdkManager.getInstance(FEATURE_TYPE.BARCODE); scanner = barcodeManager.getDevice(BarcodeManager.DeviceIdentifier.DEFAULT); try { scanner.triggerType = Scanner.TriggerType.HARD; scanner.disable(); } catch (ScannerException e) { e.printStackTrace(); }}
When I stay in Main Activity the scan is off, Then I move to another activity, at that moment the scanner is turned on again, in the settings of the emdk the property (Barcode Scanner Input is selected as enable) because the data wedge is active.
I still can not find how to make the scanner continue off in PriceVerifierActivity or Video Activity.
I try to send the Scanner reference through an Intent and from the other activity disable it again but it does not disable it, I print the status of the scanner and it prints "disabled", but the scanner continues on.
I think about using fragments instead of activities to solve the problem.
I was able to turn off the scanner, the problem was the finish method () of the previous activity, the problem I have now is that when the scanner light turns on it does not scan a bar code, I do not know if I have to recover it again some profile data.
I am sorry I am not able to help you more but from what I recall, this device handled scanning slightly different from our other scanning devices so without a physical device I am making guesses. You would get better support by contacting our technical support team : https://www.zebra.com/gb/en/about-zebra/contact-zebra/contact-tech-support.html
I had not realised the EMDK supported the CC5000 device but it seems that the device was supported up to and including EMDK 6.7. You might get more reliable behaviour if you disabled DataWedge entirely since use of the EMDK and DataWedge are mutually exclusive, you would not typically combine them in the same application. You should be able to disable DW from the DW settings screen: http://techdocs.zebra.com/datawedge/6-6/guide/settings/
Thanks for this recommendation. I was doing performance tests of the application, after scanning 1:30 hours, turn on the light of the scanner but it does not scan, if I close and open the application, it returns to scan without any problem, the memory remains constant, I have no idea that It may be happening, it does not show any exception, I hope someone can help me.
Memory
1.- When the application starts, i scan an item, then the scanner is disable, when the information is shown, the scanner is enabled.
`package com.symbol.wmpriceverifier;
import android.content.Intent; import android.os.Build; import android.os.Bundle; import android.os.Handler; import android.support.v7.app.AppCompatActivity; import android.view.MotionEvent; import android.view.View; import android.widget.Button; import android.widget.Toast;
import com.symbol.emdk.EMDKManager; import com.symbol.emdk.EMDKManager.FEATURE_TYPE; import com.symbol.emdk.EMDKResults; import com.symbol.emdk.ProfileManager; import com.symbol.emdk.barcode.BarcodeManager; import com.symbol.emdk.barcode.ScanDataCollection; import com.symbol.emdk.barcode.Scanner; import com.symbol.emdk.barcode.ScannerException; import com.symbol.emdk.barcode.StatusData; import com.symbol.wmpriceverifier.mail.EmailContentBuilder; import com.symbol.wmpriceverifier.mail.ErrorEmailBean; import com.symbol.wmpriceverifier.mail.SendNotificationTask; import com.symbol.wmpriceverifier.utils.NetworkDetails; import com.symbol.wmpriceverifier.utils.PriceVerifierConstants; import com.symbol.wmpriceverifier.utils.ToastMessageDuration;
/**
*/ public class MainActivity extends FlexPriceVerifierActivity implements View.OnClickListener ,Runnable, EMDKManager.EMDKListener, Scanner.DataListener, Scanner.StatusListener, View.OnTouchListener
{ /**
Declare the button for open the scanner upc. */ private Button showIdVerifier;
/**
Declare a variable to store ProfileManager object */ private ProfileManager mainProfileManager;
/**
Declare a variable to store EMDKManager object */ private EMDKManager emdkManager;
/**
Allows process Runnable objects associated with a thread's. */ private Handler handler;
/**
This is the scanner. */ private Scanner scanner;
/**
This is a starting time for the IP/Device ID button. */ private long timeInActionDown=0L;
private int countException=0;
/**
@param savedInstanceState */ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main);
showIdVerifier=findViewById(R.id.showIdVerifier);
showIdVerifier.setOnTouchListener(this);
EMDKResults results = EMDKManager.getEMDKManager(getApplicationContext(), this);
}
/**
@param intent */ public void validateScanAction(Intent intent){ if(intent!=null){
//Check if the intent corresponds to the back action.
//If the intent.getExtras() is not null, it's because the scanning action is over.
//We don't need to do anything if the action is null, because the action already finished.
if(intent.getExtras()!=null){
String upcParameter=intent.getExtras().getString(PriceVerifierConstants.UPC_KEY);
if(upcParameter!=null){
onNewIntent(intent);
}
}
//Checks if you have the right broadcast intent, the action corresponds to EMDK.
//If the intent.getAction() is not null, we can get the upc scanned. We don't need to do
//anything if the action is null.
if(intent.getAction()!=null){
boolean contentAction =intent.getAction().contentEquals(PriceVerifierConstants.EMDK_SAMPLE_RECVR);
if(contentAction){
onNewIntent(intent);
}
}
}
}
/**
Calls the Scanner Upc activity for put the upc of the item scanned. */ public void openScanner() {
Intent intent = new Intent(this, ScannerUpcActivity.class);
startActivity(intent);
}
private Runnable mainTimerExecutor = this;
/**
@param emdkManager */ @Override public void onOpened(EMDKManager emdkManager) { this.emdkManager = emdkManager;
mainProfileManager = (ProfileManager)emdkManager.getInstance(EMDKManager.FEATURE_TYPE.PROFILE);
if(mainProfileManager != null) {
mainProfileManager
.processProfile(PriceVerifierConstants.PROFILE_NAME, ProfileManager.PROFILE_FLAG.SET, new String[1]);
}
Intent intent = getIntent();
intent.putExtra(UPC_IS_EMPTY_EXTRA, true);
validateScanAction(intent);
}
/**
Clean up the objects created by EMDK manager. */ @Override protected void onDestroy() { handler.removeCallbacks(mainTimerExecutor); super.onDestroy();
if(mainProfileManager!=null){
mainProfileManager=null;
}
if(emdkManager!=null){
emdkManager.release();
emdkManager=null;
}
}
/**
@param intentData */ private void handleDecodeData(Intent intentData) { try{
disableScanner();
Intent sendIntent = new Intent(this, PriceVerifierActivity.class);
if(intentData.getExtras() != null) {
String upcScanned = intentData.getStringExtra(PriceVerifierConstants.UPC_TEXT_VIEW_VALUE);
if(upcScanned != null) {
sendIntent.putExtra(PriceVerifierConstants.UPC_TEXT_VIEW_VALUE, upcScanned);
}
}
if(intentData.getAction() != null) {
if(intentData.getAction().contentEquals(PriceVerifierConstants.EMDK_INTENT_ACTION)) {
// Get the source of the data
String source = intentData.getStringExtra(PriceVerifierConstants.EMDK_SOURCE_DATA);
// Check if the data has come from the Barcode scanner
if(source.equalsIgnoreCase(PriceVerifierConstants.DATA_SCANNER)) {
// Get the data from the intent
String data = intentData.getStringExtra(PriceVerifierConstants.EMDK_INTENT_DATA);
// Check that we have received data
if(data != null && data.length() > 0) {
sendIntent.putExtra(PriceVerifierConstants.UPC_TEXT_VIEW_VALUE, data);
}
}
}
}
startActivity(sendIntent);
}catch(Exception ex){
ex.printStackTrace();
}
}
/**
@param intent */ @Override public void onNewIntent(Intent intent) { Bundle dataIntent = intent.getExtras(); String upc = EMPTY_STRING; boolean turnScannerOn = false;
if(!(dataIntent.getBoolean(UPC_IS_EMPTY_EXTRA)&&dataIntent.getBoolean(START_SCANNER_EXTRA)) ){
if(dataIntent != null) {
turnScannerOn = dataIntent.getBoolean(START_SCANNER_EXTRA);
String upcScanned=dataIntent.getString(PriceVerifierConstants.UPC_KEY);
if( upcScanned!= null
&& !upcScanned.isEmpty()) {
upc = upcScanned;
}
}
// As this method is being triggered every time a new Intent occurs, we have to detour
// to enabling the scanner or to read the UPC.
if(turnScannerOn){
enableScanner();
}else if (upc.equals(EMPTY_STRING)
&& !dataIntent.getBoolean(UPC_IS_EMPTY_EXTRA)) {
handleDecodeData(intent);
}
}
}
/**
The method is implemented from the EMDKManager interface. */ @Override public void onClosed() {
}
/**
Remove the call backs in the timer. */ @Override public void onStop() { handler.removeCallbacks(mainTimerExecutor); super.onStop(); }
/**
@param view */ @Override public void onClick(View view) { Toast.makeText(this, Build.SERIAL, Toast.LENGTH_SHORT).show(); }
/**
Thread that count the seconds before change the screen. */ @Override public void run() { Intent intent = new Intent(MainActivity.this, VideoActivity.class); intent.putExtra(START_SCANNER_EXTRA, true); startActivity(intent); }
/**
Return to the video when you are in the main activity screen. */ @Override public void onResume(){ super.onResume(); handler = new Handler(); handler.postDelayed(mainTimerExecutor, PriceVerifierConstants.MAX_DELAY_MILLIS); }
/**
Disable the scanner (DataWedge and EMDK). */ public void disableScanner(){ barcodeManager = (BarcodeManager)emdkManager.getInstance(FEATURE_TYPE.BARCODE); scanner = barcodeManager.getDevice(BarcodeManager.DeviceIdentifier.DEFAULT);
try {
scanner.triggerType = Scanner.TriggerType.HARD;
scanner.disable();
}
catch(ScannerException e) {
EmailContentBuilder emailContentBuilder= new EmailContentBuilder();
ErrorEmailBean errorMailBean= emailContentBuilder.buildEmailContent(e);
SendNotificationTask sendNotificationTask= new SendNotificationTask();
sendNotificationTask.execute(errorMailBean);
}
}
/**
This method enables the scanner (EMDK only). */ public void enableScanner(){
barcodeManager = (BarcodeManager)emdkManager.getInstance(FEATURE_TYPE.BARCODE);
scanner = barcodeManager.getDevice(BarcodeManager.DeviceIdentifier.DEFAULT);
try {
if (scanner.isReadPending()){
scanner.cancelRead();
}
scanner.enable();
scanner.triggerType = Scanner.TriggerType.SOFT_ONCE;
scanner.addDataListener(this);
scanner.addStatusListener(this);
scanner.read();
}
catch(ScannerException e) {
EmailContentBuilder emailContentBuilder= new EmailContentBuilder();
ErrorEmailBean errorMailBean= emailContentBuilder.buildEmailContent(e);
SendNotificationTask sendNotificationTask= new SendNotificationTask();
sendNotificationTask.execute(errorMailBean);
}
}
/**
@param scanDataCollection */ @Override public void onData(ScanDataCollection scanDataCollection) { if(!scanDataCollection.equals(lastScanned)){ lastScanned = scanDataCollection; String data=scanDataCollection.getScanData().get(0).getData();
Intent intent = new Intent(this, MainActivity.class);
intent.putExtra(PriceVerifierConstants.UPC_TEXT_VIEW_VALUE, data.toString());
handleDecodeData(intent);
}
}
/**
@param statusData */ @Override public void onStatus(StatusData statusData) {
}
}`
Hi,
Using below method, you can turn off the barcode scanning of Zebra device.
For that, you have to do disable plugin programmatically in onResume()
of Activity.
`// define action and data strings String scannerInputPlugin = "com.symbol.datawedge.api.ACTION"; String extraData = "com.symbol.datawedge.api.SCANNER_INPUT_PLUGIN";
public void onResume() {
// create the intent
Intent i = new Intent();
// set the action to perform
i.setAction(scannerInputPlugin);
// add additional info
i.putExtra(extraData, "DISABLE_PLUGIN");
// send the intent to DataWedge
this.sendBroadcast(i);
}`
Here is the official link of scanner input plugin.
Moreover, if you try to enable of scanner (code like from link) is not working then you have to initialize Barcode manager and scanner again like below function code.
`//Initialize/Enable Scanner public void initBarcodeAndScanner(){ if (emdkManager != null) { // Acquire the barcode manager resources initBarcodeManager()
// Enumerate scanner devices
enumerateScannerDevices()
initScanner()
}
} **
initBarcodeManager(),
enumerateScannerDevices(),
initScanner()` these three methods, you can find from this link.
Hope this answer will help to anyone in future.
Hi, I am developing an application with the zebra CC5000 device in Android, when I scan a barcode I want the scanner light to turn off and turn on until a service returns information.
I was reviewing the CC5000 device guide, I found that the DataWedge is a utility that adds advanced barcode scanning capability, I'm not sure if the change has to be configured in the dataWedge or something that can be done with the EMDK, or if it really is something that can be done.
Thanks :)