super.onCreate(savedInstanceState);
mHandler = new Handler();
mFileOperationsHelper = new FileOperationsHelper(this);
- Account account;
+ Account account = null;
if(savedInstanceState != null) {
- account = savedInstanceState.getParcelable(FileActivity.EXTRA_ACCOUNT);
mFile = savedInstanceState.getParcelable(FileActivity.EXTRA_FILE);
mFromNotification = savedInstanceState.getBoolean(FileActivity.EXTRA_FROM_NOTIFICATION);
mFileOperationsHelper.setOpIdWaitingFor(
mFromNotification = getIntent().getBooleanExtra(FileActivity.EXTRA_FROM_NOTIFICATION, false);
}
+ AccountUtils.updateAccountVersion(this); // best place, before any access to AccountManager or database
+
setAccount(account, savedInstanceState != null);
mOperationsServiceConnection = new OperationsServiceConnection();
}
-
+ @Override
+ protected void onNewIntent (Intent intent) {
+ Log_OC.v(TAG, "onNewIntent() start");
+ Account current = AccountUtils.getCurrentOwnCloudAccount(this);
+ if (current != null && mAccount != null && !mAccount.name.equals(current.name)) {
+ mAccount = current;
+ }
+ Log_OC.v(TAG, "onNewIntent() stop");
+ }
+
/**
* Since ownCloud {@link Account}s can be managed from the system setting menu,
* the existence of the {@link Account} associated to the instance must be checked
protected void onRestart() {
Log_OC.v(TAG, "onRestart() start");
super.onRestart();
- boolean validAccount =
- (mAccount != null && AccountUtils.setCurrentOwnCloudAccount(getApplicationContext(), mAccount.name));
+ boolean validAccount = (mAccount != null && AccountUtils.exists(mAccount, this));
if (!validAccount) {
swapToDefaultAccount();
}
@Override
protected void onStart() {
- Log_OC.v(TAG, "onStart() start");
super.onStart();
if (mAccountWasSet) {
onAccountSet(mAccountWasRestored);
}
- Log_OC.v(TAG, "onStart() end");
}
@Override
protected void onResume() {
- Log_OC.v(TAG, "onResume() start");
super.onResume();
if (mOperationsServiceBinder != null) {
doOnResumeAndBound();
}
- Log_OC.v(TAG, "onResume() end");
}
@Override
protected void onPause() {
- Log_OC.v(TAG, "onPause() start");
-
if (mOperationsServiceBinder != null) {
mOperationsServiceBinder.removeOperationListener(this);
}
super.onPause();
- Log_OC.v(TAG, "onPause() end");
}
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putParcelable(FileActivity.EXTRA_FILE, mFile);
- outState.putParcelable(FileActivity.EXTRA_ACCOUNT, mAccount);
outState.putBoolean(FileActivity.EXTRA_FROM_NOTIFICATION, mFromNotification);
outState.putLong(KEY_WAITING_FOR_OP_ID, mFileOperationsHelper.getOpIdWaitingFor());
outState.putBoolean(KEY_TRY_SHARE_AGAIN, mTryShareAgain);