0 Replies Latest reply on Sep 12, 2016 9:33 AM by Antonio Coentrao

    Using wrapper class in android studio

    Antonio Coentrao

      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));
         }