Android Service not active alwaysHow do save an Android Activity state using save instance state?Activity restart on rotation AndroidHow to check if a service is running on Android?Close/hide the Android Soft KeyboardWhy is the Android emulator so slow? How can we speed up the Android emulator?Stop EditText from gaining focus at Activity startupIs there a unique Android device ID?Example: Communication between Activity and Service using MessagingProper use cases for Android UserManager.isUserAGoat()?Service vs IntentService

How would I stat a creature to be immune to everything but the Magic Missile spell? (just for fun)

Can compressed videos be decoded back to their uncompresed original format?

How could indestructible materials be used in power generation?

Is it possible to create a QR code using text?

Is there an expression that means doing something right before you will need it rather than doing it in case you might need it?

If human space travel is limited by the G force vulnerability, is there a way to counter G forces?

CAST throwing error when run in stored procedure but not when run as raw query

What are some good books on Machine Learning and AI like Krugman, Wells and Graddy's "Essentials of Economics"

Avoiding the "not like other girls" trope?

Why didn't Boeing produce its own regional jet?

Am I breaking OOP practice with this architecture?

Why would the Red Woman birth a shadow if she worshipped the Lord of the Light?

How can I deal with my CEO asking me to hire someone with a higher salary than me, a co-founder?

Alternative to sending password over mail?

Method Does Not Exist error message

Can we compute the area of a quadrilateral with one right angle when we only know the lengths of any three sides?

Forgetting the musical notes while performing in concert

Why can't we play rap on piano?

Determining Impedance With An Antenna Analyzer

Would Slavery Reparations be considered Bills of Attainder and hence Illegal?

Examples of smooth manifolds admitting inbetween one and a continuum of complex structures

Is this a hacking script in function.php?

ssTTsSTtRrriinInnnnNNNIiinngg

Ambiguity in the definition of entropy



Android Service not active always


How do save an Android Activity state using save instance state?Activity restart on rotation AndroidHow to check if a service is running on Android?Close/hide the Android Soft KeyboardWhy is the Android emulator so slow? How can we speed up the Android emulator?Stop EditText from gaining focus at Activity startupIs there a unique Android device ID?Example: Communication between Activity and Service using MessagingProper use cases for Android UserManager.isUserAGoat()?Service vs IntentService













1















I use alarm service to start the service forever but this is not a solution and sometime stopped to work too ... so What is the best way to run a service always like WhatsApp?










share|improve this question




























    1















    I use alarm service to start the service forever but this is not a solution and sometime stopped to work too ... so What is the best way to run a service always like WhatsApp?










    share|improve this question


























      1












      1








      1








      I use alarm service to start the service forever but this is not a solution and sometime stopped to work too ... so What is the best way to run a service always like WhatsApp?










      share|improve this question
















      I use alarm service to start the service forever but this is not a solution and sometime stopped to work too ... so What is the best way to run a service always like WhatsApp?







      android android-service






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 8 at 6:29









      Marcin Orlowski

      58.5k892121




      58.5k892121










      asked Mar 7 at 22:17









      Ali MorselAli Morsel

      62




      62






















          1 Answer
          1






          active

          oldest

          votes


















          0














          After android oreo google restricted to run service for long time. You need to go with firebase or any persistent notification by using following code



          context.startForegroundService(intent); -> you need to put startForeground() code in the onCreate method of the service.






          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',
            autoActivateHeartbeat: false,
            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%2f55053693%2fandroid-service-not-active-always%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









            0














            After android oreo google restricted to run service for long time. You need to go with firebase or any persistent notification by using following code



            context.startForegroundService(intent); -> you need to put startForeground() code in the onCreate method of the service.






            share|improve this answer



























              0














              After android oreo google restricted to run service for long time. You need to go with firebase or any persistent notification by using following code



              context.startForegroundService(intent); -> you need to put startForeground() code in the onCreate method of the service.






              share|improve this answer

























                0












                0








                0







                After android oreo google restricted to run service for long time. You need to go with firebase or any persistent notification by using following code



                context.startForegroundService(intent); -> you need to put startForeground() code in the onCreate method of the service.






                share|improve this answer













                After android oreo google restricted to run service for long time. You need to go with firebase or any persistent notification by using following code



                context.startForegroundService(intent); -> you need to put startForeground() code in the onCreate method of the service.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 8 at 6:28









                MagudeshMagudesh

                13318




                13318





























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55053693%2fandroid-service-not-active-always%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







                    Popular posts from this blog

                    AWS Lex not identifying response if by a variable The 2019 Stack Overflow Developer Survey Results Are In Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) The Ask Question Wizard is Live! Data science time! April 2019 and salary with experienceEnforcing custom enumeration in AWS LEX for slot valuesHow to give response based on user response in Amazon Lex?Intercepting AWS Lambda Response to a AWS Lex QueryLex chat bot error: Reached second execution of fulfillment lambda on the same utteranceamazon lex showing invalid responseLambda response send back to Lex slot?Response card in Amazon lexAmazon Lex - Lambda response return HTML to botHow can I solve 424 (Failed Dependency) (python) obtained from Amazon lex?

                    Алба-Юлія

                    Захаров Федір Захарович