GithubHelp home page GithubHelp logo

robertohuertasm / endless-service Goto Github PK

View Code? Open in Web Editor NEW
224.0 5.0 78.0 129 KB

Example of an Android Foreground Service that will never stop running.

Home Page: https://robertohuertas.com/2019/06/29/android_foreground_services

Kotlin 100.00%
android foreground-service

endless-service's Introduction

Endless Service

This is just a project showing how to run an Android Foreground Service that will never stop running.

endless-service's People

Contributors

mmaterowski avatar robertohuertasm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

endless-service's Issues

Not work after application die.

I went to the task switcher and swipes an app off the screen, then the foreground notification not show again, even I rebooted the devices the foreground not auto executed.

It is just simple foreground service, not endless service

Foreground service closes automatically

Hi, I am new in Android development and your post was very helpful in understanding how to implement foreground services
I am testing this project on Xiaomi Mi 9T but unfortunately service shuts down automatically and notification is removed after 10 minutes or so (Sometimes, it runs for 1 hour and then ends silently).
I tried to modify this example by adding android:process entry in manifest file but it wasn't really helpful

<service
     android:name=".EndlessService"
     android:process=":EndlessService"
     android:enabled="true"
     android:exported="false">
</service>

I tried to remove battery optimization restrictions from this app but it didn't help also. I've noticed that it closes even when I am using phone (so that the phone is not locked and application shouldn't be affected by Doze mode)
Could you please help me figure out how to fix this? If you need more information about my setup, please, let me know

Question about start condition on receiver

Hi,

this condition:
if (intent.action == Intent.ACTION_BOOT_COMPLETED && getServiceState(context) == ServiceState.STARTED)

shouldn't be:
if (intent.action == Intent.ACTION_BOOT_COMPLETED && getServiceState(context) == ServiceState.STOPPED)

So if the service is stopped than start it?

Thanks

Null Pointer exception occur intermittently!

java.lang.RuntimeException: Unable to create service BlockAppService: java.lang.NullPointerException: Attempt to read from field 'int com.android.server.am.UidRecord.curProcState' on a null object reference

Well never seen this with naked eyes but according to firebase logs this crash happens intermittently. Is it something which is avoidable.

Start the service on Android boot

Hi sir, i am a beginner android student. Your post has helped me a lot. But it has a small problem for Mediaproject service (android:foregroundServiceType="mediaProjection). after reboot phone it is correct that the service is restarted however it is not working (only push notifications). I started service as this code:

startActivityForResult(
            mediaProjectionManager.createScreenCaptureIntent(),
            MEDIA_PROJECTION_REQUEST_CODE
    override fun onActivityResult(
        requestCode: Int,
        resultCode: Int,
        data: Intent?
    ) 
{
if (requestCode == MEDIA_PROJECTION_REQUEST_CODE) {
            if (resultCode == Activity.RESULT_OK) {
                
                startService(
                    com.robertohuertas.endless.ScreenCaptureService.getStartIntent(
                        this,
                        resultCode,
                        data
                    )
                )
            }

I have searched for days on this issue but cant find the answer, i would love to get help. Thank you very much.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.