Calling AlarmManager in Service

后端 未结 1 1868
广开言路
广开言路 2020-12-22 06:27

Context: I am attempting to implement one service call a second service (a subclass of the first) via an AlarmManager. To do this, I needed to create a Broa

相关标签:
1条回答
  • 2020-12-22 06:55

    Am I failing to implement a method?

    Well, LocalWordSubClass seems to be devoid of methods, other than inherited ones.

    Also, you are attempting to send a broadcast Intent to a Service (via your PendingIntent), which is not going to work.

    And, the BroadcastReceiver you have defined in LocalWordSubClass is unused.

    Next, from your related comment:

    I have the initial service call a new subclass (which has access to the LocationClient) after a two minute period

    Your "new subclass" will have its own mLocationClient, unrelated to any mLocationClient from any other Service in your process.

    You appear to be attempting to implement something I wrote about in the preceding comment:

    @jsc123: "How would you recommend I give my LocationClient a two minute window to connect before polling the location?" -- you could just use AlarmManager, calling set() to get control in two minutes.

    What I meant by that was that you would use set() on AlarmManager with a getService() PendingIntent to deliver control back to your already-running Service with its already-acquired WakeLock, so that it can obtain the location, release the WakeLock, and stopSelf().

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