Firebase Job Dispatcher not Scheduling jobs on OREO devices









up vote
0
down vote

favorite












I have a firebase job dispatcher which is scheduled to run whenever network changes ,the job is working perfectly on a marshmallow device (23 API level) but the same code when run is not scheduling jobs on a oreo device(26 API level)



Here is my Job Service code:



public class MyJobService extends JobService 


@Override
public boolean onStartJob(JobParameters job)

Log.d("Executing","Job");
Realm realm = Realm.getDefaultInstance();

RealmResults<JsontoSend> realmResults = realm.where(JsontoSend.class).findAll();
if(!realmResults.isEmpty())
for (JsontoSend jsontoSend : realmResults)
final Intent intent = new Intent(getApplicationContext(), PostUploadIntentService.class);
intent.putExtra("object", jsontoSend.getJson());
new Thread(new Runnable()
@Override
public void run()
startService(intent);

).run();




return true;


@Override
public boolean onStopJob(JobParameters job)
Log.d("instopjob","cancelled");
return true;





This is my code where i have created the job :



 synchronized public static void schedule(@NonNull final Context context)
if(sInitialized)
return;

Driver driver=new GooglePlayDriver(context);
FirebaseJobDispatcher dispatcher=new FirebaseJobDispatcher(driver);

Job myJob = dispatcher.newJobBuilder()
.setService(MyJobService.class)
.setTag(JOB_TAG)
.setRecurring(true)
.setTrigger(Trigger.executionWindow(5, 60))
.setLifetime(Lifetime.FOREVER)
.setConstraints(Constraint.ON_ANY_NETWORK)
.setReplaceCurrent(false)
.setRetryStrategy(RetryStrategy.DEFAULT_EXPONENTIAL)
.build();

dispatcher.schedule(myJob);
sInitialized=true;




What i am trying to do is if i do not have internet connection then storing the data in local database and then running a job whenever i connect to internet and sync the data with server .The above code is working perfectly on marshmallow device but the job is never scheduled on oreo devices.










share|improve this question























  • Sorry man, I have no idea why it doesn't work. But why do you use the firebase scheduler? Do you target on devices before 5.0 ?
    – Flavio
    Nov 12 at 18:04











  • @Flavio can you give me some other approach that works on oreo devices for the same(i mean sync data to server whenever internet is connected).
    – shashank chandak
    Nov 12 at 18:06














up vote
0
down vote

favorite












I have a firebase job dispatcher which is scheduled to run whenever network changes ,the job is working perfectly on a marshmallow device (23 API level) but the same code when run is not scheduling jobs on a oreo device(26 API level)



Here is my Job Service code:



public class MyJobService extends JobService 


@Override
public boolean onStartJob(JobParameters job)

Log.d("Executing","Job");
Realm realm = Realm.getDefaultInstance();

RealmResults<JsontoSend> realmResults = realm.where(JsontoSend.class).findAll();
if(!realmResults.isEmpty())
for (JsontoSend jsontoSend : realmResults)
final Intent intent = new Intent(getApplicationContext(), PostUploadIntentService.class);
intent.putExtra("object", jsontoSend.getJson());
new Thread(new Runnable()
@Override
public void run()
startService(intent);

).run();




return true;


@Override
public boolean onStopJob(JobParameters job)
Log.d("instopjob","cancelled");
return true;





This is my code where i have created the job :



 synchronized public static void schedule(@NonNull final Context context)
if(sInitialized)
return;

Driver driver=new GooglePlayDriver(context);
FirebaseJobDispatcher dispatcher=new FirebaseJobDispatcher(driver);

Job myJob = dispatcher.newJobBuilder()
.setService(MyJobService.class)
.setTag(JOB_TAG)
.setRecurring(true)
.setTrigger(Trigger.executionWindow(5, 60))
.setLifetime(Lifetime.FOREVER)
.setConstraints(Constraint.ON_ANY_NETWORK)
.setReplaceCurrent(false)
.setRetryStrategy(RetryStrategy.DEFAULT_EXPONENTIAL)
.build();

dispatcher.schedule(myJob);
sInitialized=true;




What i am trying to do is if i do not have internet connection then storing the data in local database and then running a job whenever i connect to internet and sync the data with server .The above code is working perfectly on marshmallow device but the job is never scheduled on oreo devices.










share|improve this question























  • Sorry man, I have no idea why it doesn't work. But why do you use the firebase scheduler? Do you target on devices before 5.0 ?
    – Flavio
    Nov 12 at 18:04











  • @Flavio can you give me some other approach that works on oreo devices for the same(i mean sync data to server whenever internet is connected).
    – shashank chandak
    Nov 12 at 18:06












up vote
0
down vote

favorite









up vote
0
down vote

favorite











I have a firebase job dispatcher which is scheduled to run whenever network changes ,the job is working perfectly on a marshmallow device (23 API level) but the same code when run is not scheduling jobs on a oreo device(26 API level)



Here is my Job Service code:



public class MyJobService extends JobService 


@Override
public boolean onStartJob(JobParameters job)

Log.d("Executing","Job");
Realm realm = Realm.getDefaultInstance();

RealmResults<JsontoSend> realmResults = realm.where(JsontoSend.class).findAll();
if(!realmResults.isEmpty())
for (JsontoSend jsontoSend : realmResults)
final Intent intent = new Intent(getApplicationContext(), PostUploadIntentService.class);
intent.putExtra("object", jsontoSend.getJson());
new Thread(new Runnable()
@Override
public void run()
startService(intent);

).run();




return true;


@Override
public boolean onStopJob(JobParameters job)
Log.d("instopjob","cancelled");
return true;





This is my code where i have created the job :



 synchronized public static void schedule(@NonNull final Context context)
if(sInitialized)
return;

Driver driver=new GooglePlayDriver(context);
FirebaseJobDispatcher dispatcher=new FirebaseJobDispatcher(driver);

Job myJob = dispatcher.newJobBuilder()
.setService(MyJobService.class)
.setTag(JOB_TAG)
.setRecurring(true)
.setTrigger(Trigger.executionWindow(5, 60))
.setLifetime(Lifetime.FOREVER)
.setConstraints(Constraint.ON_ANY_NETWORK)
.setReplaceCurrent(false)
.setRetryStrategy(RetryStrategy.DEFAULT_EXPONENTIAL)
.build();

dispatcher.schedule(myJob);
sInitialized=true;




What i am trying to do is if i do not have internet connection then storing the data in local database and then running a job whenever i connect to internet and sync the data with server .The above code is working perfectly on marshmallow device but the job is never scheduled on oreo devices.










share|improve this question















I have a firebase job dispatcher which is scheduled to run whenever network changes ,the job is working perfectly on a marshmallow device (23 API level) but the same code when run is not scheduling jobs on a oreo device(26 API level)



Here is my Job Service code:



public class MyJobService extends JobService 


@Override
public boolean onStartJob(JobParameters job)

Log.d("Executing","Job");
Realm realm = Realm.getDefaultInstance();

RealmResults<JsontoSend> realmResults = realm.where(JsontoSend.class).findAll();
if(!realmResults.isEmpty())
for (JsontoSend jsontoSend : realmResults)
final Intent intent = new Intent(getApplicationContext(), PostUploadIntentService.class);
intent.putExtra("object", jsontoSend.getJson());
new Thread(new Runnable()
@Override
public void run()
startService(intent);

).run();




return true;


@Override
public boolean onStopJob(JobParameters job)
Log.d("instopjob","cancelled");
return true;





This is my code where i have created the job :



 synchronized public static void schedule(@NonNull final Context context)
if(sInitialized)
return;

Driver driver=new GooglePlayDriver(context);
FirebaseJobDispatcher dispatcher=new FirebaseJobDispatcher(driver);

Job myJob = dispatcher.newJobBuilder()
.setService(MyJobService.class)
.setTag(JOB_TAG)
.setRecurring(true)
.setTrigger(Trigger.executionWindow(5, 60))
.setLifetime(Lifetime.FOREVER)
.setConstraints(Constraint.ON_ANY_NETWORK)
.setReplaceCurrent(false)
.setRetryStrategy(RetryStrategy.DEFAULT_EXPONENTIAL)
.build();

dispatcher.schedule(myJob);
sInitialized=true;




What i am trying to do is if i do not have internet connection then storing the data in local database and then running a job whenever i connect to internet and sync the data with server .The above code is working perfectly on marshmallow device but the job is never scheduled on oreo devices.







android job-scheduling firebase-job-dispatcher






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 11 at 7:30

























asked Nov 10 at 16:45









shashank chandak

175111




175111











  • Sorry man, I have no idea why it doesn't work. But why do you use the firebase scheduler? Do you target on devices before 5.0 ?
    – Flavio
    Nov 12 at 18:04











  • @Flavio can you give me some other approach that works on oreo devices for the same(i mean sync data to server whenever internet is connected).
    – shashank chandak
    Nov 12 at 18:06
















  • Sorry man, I have no idea why it doesn't work. But why do you use the firebase scheduler? Do you target on devices before 5.0 ?
    – Flavio
    Nov 12 at 18:04











  • @Flavio can you give me some other approach that works on oreo devices for the same(i mean sync data to server whenever internet is connected).
    – shashank chandak
    Nov 12 at 18:06















Sorry man, I have no idea why it doesn't work. But why do you use the firebase scheduler? Do you target on devices before 5.0 ?
– Flavio
Nov 12 at 18:04





Sorry man, I have no idea why it doesn't work. But why do you use the firebase scheduler? Do you target on devices before 5.0 ?
– Flavio
Nov 12 at 18:04













@Flavio can you give me some other approach that works on oreo devices for the same(i mean sync data to server whenever internet is connected).
– shashank chandak
Nov 12 at 18:06




@Flavio can you give me some other approach that works on oreo devices for the same(i mean sync data to server whenever internet is connected).
– shashank chandak
Nov 12 at 18:06












1 Answer
1






active

oldest

votes

















up vote
0
down vote













well the problem here is probably because you use GooglePlayDriver which relies on google play services to be presented on the devices. If the services are not available the job will not be scheduled.
So if you target on devices higher than 5.0 (which is true in most cases) you have to use android's JobScheduler build in since lollipop.






share|improve this answer




















    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53241140%2ffirebase-job-dispatcher-not-scheduling-jobs-on-oreo-devices%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    0
    down vote













    well the problem here is probably because you use GooglePlayDriver which relies on google play services to be presented on the devices. If the services are not available the job will not be scheduled.
    So if you target on devices higher than 5.0 (which is true in most cases) you have to use android's JobScheduler build in since lollipop.






    share|improve this answer
























      up vote
      0
      down vote













      well the problem here is probably because you use GooglePlayDriver which relies on google play services to be presented on the devices. If the services are not available the job will not be scheduled.
      So if you target on devices higher than 5.0 (which is true in most cases) you have to use android's JobScheduler build in since lollipop.






      share|improve this answer






















        up vote
        0
        down vote










        up vote
        0
        down vote









        well the problem here is probably because you use GooglePlayDriver which relies on google play services to be presented on the devices. If the services are not available the job will not be scheduled.
        So if you target on devices higher than 5.0 (which is true in most cases) you have to use android's JobScheduler build in since lollipop.






        share|improve this answer












        well the problem here is probably because you use GooglePlayDriver which relies on google play services to be presented on the devices. If the services are not available the job will not be scheduled.
        So if you target on devices higher than 5.0 (which is true in most cases) you have to use android's JobScheduler build in since lollipop.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 12 at 18:22









        Flavio

        5,20832528




        5,20832528



























             

            draft saved


            draft discarded















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53241140%2ffirebase-job-dispatcher-not-scheduling-jobs-on-oreo-devices%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            這個網誌中的熱門文章

            Barbados

            How to read a connectionString WITH PROVIDER in .NET Core?

            Node.js Script on GitHub Pages or Amazon S3