+ @Override
+ protected void onResume() {
+ super.onResume();
+
+ if (mOperationsServiceBinder != null) {
+ doOnResumeAndBound();
+ }
+
+ }
+
+ @Override
+ protected void onPause() {
+ // Save cookies here
+ Log_OC.wtf(TAG, "Saving Cookies" );
+ if (mAccount != null) {
+ try {
+ ((MainApp)getApplicationContext()).getOwnCloudClientManager().
+ saveClient(mAccount, this);
+
+ // TODO get rid of the exceptions
+ } catch (AccountNotFoundException e) {
+ e.printStackTrace();
+ } catch (AuthenticatorException e) {
+ e.printStackTrace();
+ } catch (OperationCanceledException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ if (mOperationsServiceBinder != null) {
+ mOperationsServiceBinder.removeOperationListener(this);
+ }
+
+ super.onPause();
+ }
+
+
+ @Override
+ protected void onDestroy() {
+ if (mOperationsServiceConnection != null) {
+ unbindService(mOperationsServiceConnection);
+ mOperationsServiceBinder = null;
+ }
+ if (mDownloadServiceConnection != null) {
+ unbindService(mDownloadServiceConnection);
+ mDownloadServiceConnection = null;
+ }
+ if (mUploadServiceConnection != null) {
+ unbindService(mUploadServiceConnection);
+ mUploadServiceConnection = null;
+ }
+ super.onDestroy();
+ }
+