Using wrapper class in android studio

A Antonio Coentrao 3 years 7 months ago
2 0 0

I've implemented a wrapper class according to this guide for the barcode functionality and when I try to use this wrapper class in my activity I get a nullpointerexception for the barcodeManager. When debugging I verify that the OnOpened method of the EMDKListener interface is not being called. Any hint? Here is the partial code for the wrapper class:
 
public class ZebraBarcode implements EMDKListener, DataListener, StatusListener{
   
    private Context mContext=null;
    private EMDKManager mEmdkManager=null;
    private BarcodeManager mBarcodeManager=null;
    private Scanner mScanner=null;
    private ScanDataCollection mScanDataCollection=null;
    private StatusData mStatusData=null;
   
    public ZebraBarcode(Context context){
        this.mContext=context;
    }
 
    public boolean getEMDKManager(){
        boolean bManager=true;
        EMDKResults results = EMDKManager.getEMDKManager(mContext, this);
        if(results.statusCode != EMDKResults.STATUS_CODE.SUCCESS){
            bManager=false;
        }
        return bManager;
    }   
   
    @Override
    public void onOpened(EMDKManager emdkManager) {
        this.mEmdkManager=emdkManager;
    }
 
In my activity I call this class:
 
if(Build.MANUFACTURER.contains("Zebra Technologies")
  || Build.MANUFACTURER.contains("Motorola Solutions")){
   mBarcodeSystem = new ZebraBarcode(mContext);  if(!mBarcodeSystem.getEMDKManager()){
  Log.e(TAG,mContext.getString(R.string.error_message_barcode_manager_not_initiated));   }

CONTACT
Can’t find what you’re looking for?