getApplicationContext() returns null in a Service

前端 未结 1 1853
终归单人心
终归单人心 2021-01-11 17:59

I have a Service in it\'s own process, I\'ve declared it in manifest like that:

   

        
1条回答
  •  时光说笑
    2021-01-11 18:23

    You are running your Service in a different process so it has no communication with the Actual Application process..

    Try to remove this line from your service

    android:process=":pointservice"
    

    After your application is finished Application context is becomes null. At most situations there is no need to run the service in a different process. Also it is not recommended.

    For more information check here

    1. Service in another process
    2. service reference Example2

    0 讨论(0)
提交回复
热议问题