Killing app (pid 1724) because provider is in dying process

前端 未结 5 704
南方客
南方客 2021-02-03 11:58

A Provider is implemented in application and application updates provider data and triggers a remote service which queries the provider to retrieve the stored values.The appli

5条回答
  •  别跟我提以往
    2021-02-03 12:31

    I encountered the same issue. In my case, the provider is not a 3rd party but provided by system package. The log indicate that the provider has crashed, and since my IntentService is using that provider, my IntentService got killed as a result.

    For my case, I modified my IntentService to return START_STICKY in onStartCommand(). This helps in my case because after my service got killed, the OS restart my service again and rerun everything.

    Extract from the documentation about START_STICKY flag:

    ... if this service's process is killed while it is started (after returning from onStartCommand(Intent, int, int)), then leave it in the started state but don't retain this delivered intent. Later the system will try to re-create the service. Because it is in the started state, it will guarantee to call onStartCommand(Intent, int, int) after creating the new service instance ...

    This mode makes sense for things that will be explicitly started and stopped to run for arbitrary periods of time, such as a service performing background music playback.

    https://developer.android.com/reference/android/app/Service.html#START_STICKY

提交回复
热议问题