/**
* Links the application with the user's Dropbox account.
*If the account was not linked before then the user will be shown an authentication form.
*The AccountReady event will be raised when the account is ready.
*/
public void LinkAccount(final BA ba) {
if (manager.hasLinkedAccount()) {
try {
// Use Dropbox datastores
mDatastoreManager = DbxDatastoreManager.forAccount(manager.getLinkedAccount());
} catch (DbxException.Unauthorized e) {
System.out.println("Account was unlinked remotely");
}
if (mDatastoreManager == null) {
// Account isn't linked yet, use local datastores
mDatastoreManager = DbxDatastoreManager.localManager(manager);
}
//try {
// datastore = mDatastoreManager.openDefaultDatastore();
//} catch (DbxException e) {
// System.out.println("Account was unlinked remotely");
//}
waitForFileSystem(ba);
return;
}
ion = new IOnActivityResult() {
@Override
public void ResultArrived(int resultCode, Intent intent) {
if (resultCode != Activity.RESULT_OK)
ba.raiseEvent(DbxAccountManagerWrapper.this, eventName + "_accountready", false);
else
waitForFileSystem(ba);
}
};
try {
ba.startActivityForResult(ion, null);
} catch (NullPointerException npe) {
//required...
}
BA.SharedProcessBA sba = ba.sharedProcessBA;
try {
Field f = BA.SharedProcessBA.class.getDeclaredField("onActivityResultCode");
f.setAccessible(true);
int requestCode = f.getInt(sba) - 1;
manager.startLink((Activity)ba.sharedProcessBA.activityBA.get().activity, requestCode);
} catch (Exception e) {
throw new RuntimeException(e);
}
}