Skip to content

Commit

Permalink
Handle the edge case where the app has been minimized while the servi…
Browse files Browse the repository at this point in the history
…ce is starting
  • Loading branch information
christianrowlands committed Feb 19, 2024
1 parent 2483251 commit c801432
Showing 1 changed file with 15 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -749,15 +749,21 @@ private void hideSoftInputFromWindow()

private void startAndBindToService()
{
// Start the service
Timber.i("Binding to the service");
final Intent serviceIntent = new Intent(applicationContext, getServiceClass());
applicationContext.startService(serviceIntent);

// Bind to the service
ServiceConnection surveyServiceConnection = new SurveyServiceConnection();
final boolean bound = applicationContext.bindService(serviceIntent, surveyServiceConnection, Context.BIND_ABOVE_CLIENT);
Timber.i("%s service bound in the AConnectionFragment: %s", getServiceClass().getSimpleName(), bound);
try
{
// Start the service
Timber.i("Binding to the service");
final Intent serviceIntent = new Intent(applicationContext, getServiceClass());
applicationContext.startService(serviceIntent);

// Bind to the service
ServiceConnection surveyServiceConnection = new SurveyServiceConnection();
final boolean bound = applicationContext.bindService(serviceIntent, surveyServiceConnection, Context.BIND_ABOVE_CLIENT);
Timber.i("%s service bound in the AConnectionFragment: %s", getServiceClass().getSimpleName(), bound);
} catch (Exception e)
{
Timber.e(e, "Could not start the Service");
}
}

protected abstract Class<?> getServiceClass();
Expand Down

0 comments on commit c801432

Please sign in to comment.