Dropbox Sync Library

stefanoa

Active Member
Licensed User
Longtime User
This means that the activity was not running when the event was raised. The event will be executed when the activity resumes.

You can use a service instead. Services are not paused like activities (and are easier to work with).
Thanks
 

stefanoa

Active Member
Licensed User
Longtime User
Caused by: java.lang.NullPointerException
at anywheresoftware.b4a.dropbox.DbxAccountManagerWrapper.LinkAccount(DbxAccountManagerWrapper.java:89)

i use this function in two version of same app (free and full), without differences.
In free version it work, but in full (same form, same function, same dropbox key) i get this error. I can use same key and secret for two app, right?

Any ideas?

B4X:
DropboxManager.Initialize(key, secret, "dropboxmanager")
...
DropboxManager.LinkAccount
....
 
Last edited:

Claude Brun

Active Member
Licensed User
Longtime User
Hello,
At first one thank you for your software Basic4Android. It is really brilliant.
Excuse for my English which is not very good.

I wrote an app which uses the functions of the bookshop Dropbox Sync. It works well, but I have 2 problems:
- When a file already exists on dropbox and when I make an upload, the new version does not crush the old one on dropbox
- I do not know how to delete a file on dropbox since my application Thank you in advance for your help
 
Last edited:

albgreco

Member
Licensed User
Longtime User
Hello,
I succeded in installing the Dropbox library. However, it works only if I use manager.UnlinkAccount before linkAccount as in the code below:

Sub Activity_Create(FirstTime As Boolean)
manager.Initialize(key, secret, "manager")
manager.UnlinkAccount
manager.linkAccount
Dim success As Boolean
Dim xyz
xyz=Manager_AccountReady(success)
If success Then
manager.uploadFile("/", Main.nomedatabase, File.DirRootExternal, Main.nomedatabase)
StartActivity (Main)
Else
Msgbox("Dropbox connection failed","")
End If
StartActivity (Main)
End Sub

So it works only once (and correctly synchronizes my database), unless I unlink the account every time, and as I understood this is not the correct procedure.

Any help? Thank you
 

albgreco

Member
Licensed User
Longtime User
See the example code in post #1. You should initialize Manager when FirstTime is True and only link it once.
Thanks. But this means that I should unlink also at FirstTime, before initialize and link account? if I try to just initialize and link, I don't get success when calling Manager_AccountReady.
So the Dropbox screen (asking for consent to Dropbox file access authorization) should normally be invoked at every program execution/restart?
 

albgreco

Member
Licensed User
Longtime User
You should initialize it once when FirstTime is True.

Do you want to link the account immediately when your app starts?

Perhaps I don't understand properly what "linking the account" means. I supposed that the Dropbox dialog for "file access consent" should appear only once in the life of a particular device, after it had been linked to Dropbox, not every time the app starts. Perhaps I was mistaken because PC Dropbox is "machine-based", not "app-based".

So my question is: what happens after the first linking (i.e.: answering Yes, I consent file access)? how long is Dropbox supposed to remember this linking? So there is really need to Unlink the account every time the app starts before linking? (see capitalized comment in the code below)

Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
manager.Initialize(key, secret, "manager")
manager.UnlinkAccount 'IF THIS LINE IS MISSING IT DOES'NT WORK
manager.linkAccount
End If
Dim success As Boolean
Dim xyz
xyz=Manager_AccountReady(success)
If success Then
manager.uploadFile("/", Main.nomedatabase, File.DirRootExternal, Main.nomedatabase)
StartActivity (Main)
Else
Msgbox("Dropbox connection failed","")
End If
StartActivity (Main)
End Sub
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Please use [ code ] [ /code ] tags (without spaces) when posting code.

I tried this code and it worked fine:
B4X:
Sub Activity_Create(FirstTime As Boolean)
   If FirstTime Then
     manager.Initialize("xxx", "yyy", "manager")
     manager.LinkAccount
   End If
   Activity.LoadLayout("1")
End Sub

Which error do you get when you don't call UnlinkAccount?

According to Dropbox documentation the user should only need to approve the link once.
 

albgreco

Member
Licensed User
Longtime User

If I install the app without UnlinkAccount, Manager_AccountReady does not return success. Yet, even if no success, changed files are automatically synchronized with Dropbox for a while. This works until the app is active (no device restart, no app reinstall).
When I reinstall the app (which is usual during program debugging) it does'nt work at all (no success, no synchro). In this case, to make it working again, Unlink is needed before linking.
It seems that I must resign and accept the Dropbox approving dialog every time the app restarts. Thank you again in any case for help.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…