Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configurable scan job ids #645

Merged
merged 3 commits into from
Feb 23, 2018
Merged

Configurable scan job ids #645

merged 3 commits into from
Feb 23, 2018

Conversation

davidgyoung
Copy link
Member

The Job Scheduler ScanJobs used in Android 8 has a hard-coded job id of 1 and 2. Because this job id must be unique per application, this can cause collisions with other app job ids. This changes the default job ids to be a high integer number, and declares them in AndroidManifest.xml:

        <service android:name=".service.ScanJob"
                android:permission="android.permission.BIND_JOB_SERVICE" >
            <meta-data android:name="immmediateScanJobId" android:value="208352939" />
            <meta-data android:name="periodicScanJobId" android:value="208352940" />
        </service>

These may be overridden in the app manifest as needed like this:

        <service android:name="org.altbeacon.beacon.service.ScanJob">
            <meta-data android:name="immediateScanJobId" android:value="1000" tools:replace="android:value"/>
            <meta-data android:name="periodicScanJobId" android:value="1001" tools:replace="android:value"/>
        </service>

The job ids may also be changed programmatically with:

        ScanJob.setOverridePeriodicScanJobId(100);
        ScanJob.setOverrideImmediateScanJobId(101);

However, for third party apps using the library the programmatic syntax should be avoided as it accesses a private API and is not guaranteed to be supported in future releases.

This resolves #582

@dietert
Copy link

dietert commented Mar 23, 2018

Hi David

I suppose that "immmediateScanJobId" with 3 'm'-s is a typo in the documentation?

Regards
Dieter

@davidgyoung
Copy link
Member Author

davidgyoung commented Mar 25, 2018

Yes, this is a typo in the documentation which I just fixed here. Thanks for noting it This same typo actually was in the AndroidManifest.xml for the library when it was released in version 2.13, but it was quickly updated in minor release 2.13.1 in #653

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Used jobIds should be documented and configurable
2 participants