1 Reply Latest reply on Apr 19, 2016 9:29 AM by Kanagal Raj Ramaswamy

    EMDKWrapper class for non-Zebra devices concerns

    Jacek Rys

      Hello,

       

      I'm trying to create EMDKWrapper class so that I could use EMDK features on non-Zebra devices (following this article).

       

      Three things are comming into my mind here:

      1. First, I cannot Override release method, so I understand it should be just public method in EMDKWrapper class and should be user in MainActivity when manager should be released (e.x.: in onDestroy method);

           Shouldn't it be only:

       

      public void release() {
         if (emdkManager != null) {
         emdkManager.release();
         emdkManager = null;
        }
      }

      without Overriding?

       

      2. Second, I'm I correctly thinking that *this* bracket should cover onOpened(EMDKManager emdkManager), onClosed() and release() method, not only getEMDKManager(Bundle savedInstanceState) method inside EMDKWrapper class?

       

      3. Third, the concern here is similar to the first one, presented above: I am not able to override getEMDKManager(Bundle savedInstanceState) in my project.

      • How can I do that?
      • Maybe it is enough to move code from getEMDKManager(Bundle savedInstanceState) to the constructor of EMDKWrapper class? Just like this:


        • Re: EMDKWrapper class for non-Zebra devices concerns
          Kanagal Raj Ramaswamy

          Here is the updated code:

           

                       Activity Class:

          public class MainActivity extends Activity {

           

                  private EMDKWrapper emdkWrapper = null;

                  @Override

                  protected void onCreate(Bundle savedInstanceState) {

                          super.onCreate(savedInstanceState);

                          /* Rebranded Zebra devices are set to “Zebra Technologies”

                           * whereas Motorola devices are set to “Motorola Solutions”.

                           * */

                          if(android.os.Build.MANUFACTURER.contains("Zebra Technologies") ||

                                          android.os.Build.MANUFACTURER.contains("Motorola Solutions") ) {

                                  emdkWrapper = new EMDKWrapper(getApplicationContext());

                          }

                  }

           

                  @Override

                  protected void onDestroy() {

                          super.onDestroy();

                          //Release the EMDKmanager on Application exit.

                          if (emdkWrapper  != null) {

                                  emdkWrapper .release();                

                          }

                  }

          }

           

          EMDK Wrapper Class:

          import com.symbol.emdk.EMDKManager;

          import com.symbol.emdk.EMDKManager.EMDKListener;

          import com.symbol.emdk.EMDKResults;

           

          import android.content.Context;

           

          public class EMDKWrapper implements EMDKListener {

                  EMDKManager emdkManager = null;

                  EMDKWrapper(Context appContext) {

                          EMDKResults results = EMDKManager.getEMDKManager(appContext, this);

                          if (results.statusCode != EMDKResults.STATUS_CODE.SUCCESS) {

                                  //Failed to request the EMDKManager

                          }

                  }

           

                  void release() {

                          //Release the EMDKmanager on Application exit.

                          if (emdkManager != null) {

                                  emdkManager.release(); 

                                  emdkManager = null;            

                          }

                  }

           

                  @Override

                  public void onOpened(EMDKManager emdkManager) {

                          this. emdkManager = emdkManager;

                          //The EMDK Manager is ready and now you can call other EMDK APIs.

                  }

           

                  @Override

                  public void onClosed() {

                          /* EMDKManager is closed abruptly.

                           *  Call EmdkManager.release() to free the resources used by the

                           * current EMDK instance.

                           * */

                          if (emdkManager != null) {

                                  emdkManager.release(); 

                                  emdkManager = null;            

                          }

                  }

          }