0

Background

We have a background IntentService that runs whether the associated app is open or closed. (the onStartCommand returns Service.START_STICKY). API Guard is being used to authenticate any API calls being made.

Problem

API calls being made from the app and the background service work fine if the app is open. However, when the app is closed, calls made from the background service fail the API Guard authentication. Reason is that there's no Activity in the background which the API Guard SDK requires.

It seems strange that the SDK would require an Activity since a background service will likely have no UI.

What I've Tried

  • Added APIGuard.getInstance().reauthenticate(); inside the onCreate() method of the background service class. This did not work.
  • Added an Activity to the background service implementation, but this not an option since the activity hijacks the focus from the service, which we can't have.

Question

Has anyone worked with something this specific on Android before? Again, I have to think API Guard has a way to handle this scenario.

killQuotes
  • 185
  • 12
  • *We have a background IntentService that runs whether the associated app is open or closed* ... IntentService is not STICKY service ... – Selvin Nov 03 '16 at 15:38
  • Perhaps my comment was unclear. More specifically, I'm overriding the IntentService's onStartCommand to: return Service.START_STICKY. – killQuotes Nov 03 '16 at 15:45
  • @Selvin Do you have any insight into my question, or are you just doing random pull request reviews today? – killQuotes Nov 03 '16 at 15:50
  • Did you read IntentService docs ... its not for sticky service ... you shouldn't override onStartCommand ... *Do you have any insight into* ... yes ... and? you didn't define: "APIGuard", "This did not work." , etc, etc ... so my comments is not clear as your question ... – Selvin Nov 03 '16 at 15:52

0 Answers0