7 Replies Latest reply on Nov 16, 2016 7:48 AM by Billie Hecox

    Device boot broadcast event

    Kishor PV

      HI,

       

      I'm trying to receive a broadcast event up on device boot(Reboot). I tried most combinations of the below intent filter types but it's never been a consistant. I'm logging and inserting few things to content provider within this receiver and I don't see it's working as expected. Is there any custom action intent filter I need to use? I noticed with few custom intent filters with few vendors.

       

      I didn't see any exceptions in the console.

       

      <receiver
         android:name="com.test.receivers.DeviceBootReceiver"
         android:enabled="true"
         android:exported="true">

        <intent-filter>

        <action android:name="android.intent.action.BOOT_COMPLETED" />

        <action android:name="android.intent.action.QUICKBOOT_POWERON" />

        <category android:name="android.intent.category.DEFAULT" />

        </intent-filter>

      </receiver>

       

      Thanks,

      Kishor PV

        • Re: Device boot broadcast event
          Billie Hecox

          Hey Kishor,

          Make sure to request permission in your manifest.

          <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />

           

          Also, your App must be launched at least one time by the user before your app will receive that broadcast at boot.

            • Re: Device boot broadcast event
              Kishor PV

              Thanks for the quick reply.

              My apologies!!! I forgot to mentioned that I've given the above user permission. Here is the steps I'm following

               

              1. I've the app installed which doesn't have any launcher icon to launch.

              2. Reboot the device.

              3. Monitor the log or the content provider data.

               

              Is there any other way to accomplish this.

                • Re: Device boot broadcast event
                  Billie Hecox

                  Kishor,

                  You could use a launcher like our Enterprise Home Screen. EHS can be configured to launch your service.

                   

                  I believe the issue you are having is that your when your app is installed, Android installs your app, but leaves it in a stopped state.  Since you do not have an activity, likely your IDE is failing to launch your service after installing. So it never gets out of the stopped state.

                   

                  I would add a small settings activity, and turn off the launcher icon in the manifest. That way the IDE will get your app out of a stopped state.

                   

                  For reference: Android 3.1 APIs | Android Developers

                  Launch controls on stopped applications

                  Starting from Android 3.1, the system's package manager keeps track of applications that are in a stopped state and provides a means of controlling their launch from background processes and other applications.

                    • Re: Device boot broadcast event
                      Kishor PV

                      How does by adding the settings activity would help to move the app from stopped state it is just another activity. Can you give some reference where I can look at it.

                       

                      I just added a dummy settings activity using android studio and turned off the launcher activity but doesn't seems like my receiver is triggered.

                        • Re: Device boot broadcast event
                          Billie Hecox

                          Hi Kishor PV,

                          That will only help during development.  When you deploy your app to the device from Android Studio, the IDE tries to launch the Main Activity associated with the app. Since you do not have an activity, the IDE fails to launch your app ( which is likely why your app is in a stopped state and cannot receive the boot complete intent).

                           

                          In production, something will have to launch your service as least once before it will receive the BootComplete Intent.  If someone goes int Settings>Apps> Your App, and Force Stops it, your service will be back in a stopped state, and something will have to launch it again to get it out of a stopped state.

                  • Re: Device boot broadcast event
                    Kishor PV

                    HI Bill,

                     

                    I'm releasing the scanner resources when the app goes to background(On pause) but I keep seeing the below set of exceptions when I just start the app and move it to back ground.

                     

                    Exceptions:

                    • com.symbol.emdk.barcode.ScannerException: Scan read is issued without adding the data listener.
                    • Already scanning. Wait for current scanning to complete.
                    • com.symbol.emdk.barcode.ScannerException: The scanner device is not enabled.

                     

                    Method:

                     

                    @Override
                    public void onStatus(StatusData statusData) {

                      StatusData.ScannerStates state = statusData.getState();

                      Log.d("scannerstatus", state.name());

                     

                       switch (state) {

                       case IDLE:

                       isScanning = false;

                       try {

                     

                      ScannerConfig config = scanner.getConfig();

                     

                      config.decoderParams.upce0.enabled = true;

                      config.decoderParams.upce0.reportCheckDigit = true;

                      config.decoderParams.upce0.preamble = ScannerConfig.Preamble.SYS_CHAR;

                     

                      config.decoderParams.upce1.enabled = true;

                      config.decoderParams.upce1.reportCheckDigit = true;

                      config.decoderParams.upce1.preamble = ScannerConfig.Preamble.SYS_CHAR;

                     

                       if (this.isListenersAttached && scanner.isEnabled()) {

                       scanner.setConfig(config);

                       scanner.read();

                      }

                     

                      } catch (ScannerException e) {

                      e.printStackTrace();

                      }

                       break;

                       case SCANNING:

                       isScanning = true;

                       break;

                       case WAITING:

                       break;

                       case DISABLED:

                       break;

                       case ERROR:

                       break;

                       default:

                       break;

                      }

                    }

                     

                    Steps:

                     

                    *After the initialising scanner and getting the home screen (hope fully scanner is in idle state).

                    * Try to tap on the menu button so that app goes to background.

                    * Exceptions in logs.

                     

                    I guess when the app goes to background scanner is trying to read and at the same time I'm releasing the emdk manager and scanner resources.

                     

                    Appreciate if you respond.

                      • Re: Device boot broadcast event
                        Billie Hecox

                        Hello Kishor PV, I have closed this discussion because the original question has been answered.  It would be best to open another discussion thread so your question will be titled properly, and when others have the same issue they can find the resolution quickly.

                         

                         

                        As to the EMDK barcode exception issue, I'm gonna need to see more of the code. could you provide a small sample app that exhibits this issue?  Also, how does your app differ from the Barcode API Sample App?