10 Replies Latest reply on Dec 6, 2015 11:54 PM by thomas.wichser@modacom.ch

    Not allowed to bind to service Intent

    thomas.wichser@modacom.ch

      Hi all

       

      after following the tutorial (https://developer.motorolasolutions.com/docs/DOC-2659) I am ending up with an error message from EMDKManager.getEMDKManager(.)

       

      The message is: Not allowed to bind to service Intent { act=symbol.intent.action.emdkservice cmp=com.symbol.emdk.emdkservice/.EMDKService }

       

      I added the required permissions to the manifest as shown in the tutorial.

       

      what now ?

       

      Cheerz

      -ToM-

        • Re: Not allowed to bind to service Intent
          Bill Hecox

          Tom, would it be possible to share your project or just your Main Activity and Manifest?

            • Re: Not allowed to bind to service Intent
              thomas.wichser@modacom.ch

              Hello Bill


              Thx for your reply.

               

              Yes of course, here's the manifest:

               

              <?xml version="1.0" encoding="utf-8"?>
              <manifest xmlns:android="http://schemas.android.com/apk/res/android"
                  package="..." >

                  <uses-permission android:name="android.permission.INTERNET" />
                  <uses-permission android:name="android.permission.READ_PHONE_STATE" />
                  <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
                  <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
                  <uses-permission android:name="android.permission.WAKE_LOCK" />
                  <uses-permission android:name="android.permission.CALL_PHONE" />
                  <uses-permission android:name="android.permission.VIBRATE" />
                  <uses-permission android:name="android.permission.CAMERA" />
                  <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
                  <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
                  <uses-permission android:name="con.symbol.emdk.permission.EMDK" />

                  <application
                      android:name=".THSApplication"
                      android:allowBackup="true"
                      android:icon="@drawable/icon"
                      android:label="@string/app_name"
                      android:theme="@style/AppTheme" >
                      <uses-library android:name="com.symbol.emdk" />
                      <receiver android:name="..." >
                          <intent-filter>
                              <action android:name="android.intent.action.ACTION_SHUTDOWN" />
                          </intent-filter>
                      </receiver>
                      <receiver android:name="..." >
                          <intent-filter>
                              <action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
                          </intent-filter>
                      </receiver>

                      <activity
                          android:name=".LoginActivity"
                          android:screenOrientation="portrait"
                          android:theme="@style/AppTheme.NoTitleBar"
                          android:windowSoftInputMode="stateVisible" >
                          <intent-filter>
                              <action android:name="android.intent.action.MAIN" />

                              <category android:name="android.intent.category.LAUNCHER" />
                          </intent-filter>
                      </activity>
                     
                  </application>

              </manifest>

               

              and here is the code for the scanning activity:

               


              public class ContainerActivity extends BaseActivity implements EMDKListener, StatusListener, DataListener {
                  public static final String EXTRA_FLIGHT = "FLIGHT";
                  private final SessionManager m_sessionManager;
                  private final RTCServer m_rtcServer;
                  private final ProfileManager m_profileManager;
                  private final ContainerManager m_containerManager;
                  private final Logger m_logger;
                  private Flight m_flight = null;
                  private ContainerListFragment m_listFragment = null;
                  private ContainerNumberFragment m_containerFragment = null;
                  private EMDKManager m_emdkManager = null;
                  private BarcodeManager m_barcodeManager = null;
                  private Scanner m_scanner = null;

                  /***
                   * Called when the activity is initializing.
                   * @param savedInstanceState If the activity is being re-initialized after previously being
                   *                           shut down then this Bundle contains the data it most recently
                   *                           supplied in onSaveInstanceState(Bundle). Otherwise it is null.
                   */
                  @Override
                  protected void onCreate(Bundle savedInstanceState) {
                      super.onCreate(savedInstanceState);
                 
                      EMDKResults results = EMDKManager.getEMDKManager(getApplicationContext(), this);
                      if(results.statusCode != EMDKResults.STATUS_CODE.SUCCESS) {
                          // ToDo
                      }

                  } // onCreate


                  private void initializeScanner() throws ScannerException {
                      if (m_scanner == null) {
                          m_barcodeManager = (BarcodeManager) this.m_emdkManager.getInstance(EMDKManager.FEATURE_TYPE.BARCODE);

                          m_scanner = m_barcodeManager.getDevice(BarcodeManager.DeviceIdentifier.DEFAULT);
                          m_scanner.addDataListener(this);
                          m_scanner.addStatusListener(this);
                          m_scanner.triggerType = Scanner.TriggerType.HARD;
                          m_scanner.enable();
                          m_scanner.read();
                      }
                  }

                  @Override
                  public void onData(ScanDataCollection scanDataCollection) {
                      new AsyncDataUpdate().execute(scanDataCollection);
                  }

                  @Override
                  public void onOpened(EMDKManager emdkManager) {
                      this.m_emdkManager = emdkManager;
                      try {
                          initializeScanner();
                      } catch (ScannerException e) {
                          e.printStackTrace();
                      }
                  }

                  @Override
                  public void onClosed() {

                  }

                  @Override
                  public void onStatus(StatusData statusData) {

                  }

                  @Override
                  protected void onDestroy() {
                      super.onDestroy();
                      if (m_emdkManager != null) {
                              m_emdkManager.release();
                              m_emdkManager = null;
                      }
                  }

                  @Override
                  protected void onStop() {
                      super.onStop();
                      try {
                          if (m_scanner != null) {
                              m_scanner.disable();
                              m_scanner = null;
                          }
                      } catch (ScannerException e) {
                          e.printStackTrace();
                      }
                  }

                  private class AsyncDataUpdate extends AsyncTask<ScanDataCollection, Void, String> {
                       @Override
                       protected String doInBackground(ScanDataCollection... params) {
                           String result = null;
                           try {
                               m_scanner.read();
                               ScanDataCollection scanDataCollection = params[0];
                               if (scanDataCollection != null && scanDataCollection.getResult() == ScannerResults.SUCCESS) {
                                   ArrayList<ScanDataCollection.ScanData> scanData = scanDataCollection.getScanData();
                                   for (ScanDataCollection.ScanData data : scanData) {
                                       result = data.getData();
                                       ScanDataCollection.LabelType labelType = data.getLabelType();
                                   } // for
                               } // if
                           } catch (ScannerException e) {
                               e.printStackTrace();
                           }
                           return result;
                       }

                       @Override
                       protected void onPostExecute(String result) {
                       }

                       @Override
                       protected void onPreExecute() {
                       }

                       @Override
                       protected void onProgressUpdate(Void... values) {
                       }
                   }

              } // ContainerActivity

               

              Cheerz

              -ToM-

            • Re: Not allowed to bind to service Intent
              Bill Hecox

              Tom, As Gary pointed out, can you change the permission name to com.symbol namespace and check to see if that fixes your issue? If so please mark Gary's reply as the correct answer.