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
....
** Activity (menu) Resume **
** Activity (menu) Pause, UserClosed = false **
** Activity (utilities) Create, isFirst = true **
** Activity (utilities) Resume **
** Service (mlbbackupdbx) Create **
** Service (mlbbackupdbx) Start **

mlbbackupdbx_backupdb_dropbox (java line: 193)

java.lang.RuntimeException: java.lang.NullPointerException
at anywheresoftware.b4a.dropbox.DbxAccountManagerWrapper.LinkAccount(DbxAccountManagerWrapper.java:91)
at bloomob.mylifebook.mlbbackupdbx._backupdb_dropbox(mlbbackupdbx.java:193)
at bloomob.mylifebook.mlbbackupdbx._service_start(mlbbackupdbx.java:273)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:170)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:154)
at bloomob.mylifebook.mlbbackupdbx.handleStart(mlbbackupdbx.java:68)
at bloomob.mylifebook.mlbbackupdbx.onStartCommand(mlbbackupdbx.java:53)
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2060)
at android.app.ActivityThread.access$2800(ActivityThread.java:124)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1011)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3717)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:864)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:622)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at anywheresoftware.b4a.dropbox.DbxAccountManagerWrapper.LinkAccount(DbxAccountManagerWrapper.java:89)
... 19 more
java.lang.RuntimeException: Unable to start service bloomob.mylifebook.mlbbackupdbx@4050b1e8 with Intent { cmp=bloomob.mylifebook/.mlbbackupdbx }: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.NullPointerException


at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2073)
at android.app.ActivityThread.access$2800(ActivityThread.java:124)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1011)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3717)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:864)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:622)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.NullPointerException
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:196)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:154)
at bloomob.mylifebook.mlbbackupdbx.handleStart(mlbbackupdbx.java:68)
at bloomob.mylifebook.mlbbackupdbx.onStartCommand(mlbbackupdbx.java:53)
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2060)
... 10 more
Caused by: java.lang.RuntimeException: java.lang.NullPointerException
at anywheresoftware.b4a.dropbox.DbxAccountManagerWrapper.LinkAccount(DbxAccountManagerWrapper.java:91)
at bloomob.mylifebook.mlbbackupdbx._backupdb_dropbox(mlbbackupdbx.java:193)
at bloomob.mylifebook.mlbbackupdbx._service_start(mlbbackupdbx.java:273)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:170)
... 14 more
Caused by: java.lang.NullPointerException
at anywheresoftware.b4a.dropbox.DbxAccountManagerWrapper.LinkAccount(DbxAccountManagerWrapper.java:89)
... 19 more
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
** Activity (menu) Create, isFirst = true **
 
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
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.

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.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Don't you see the link? Here is a screenshot:

SS-2013-11-17_08.56.38.png
 
Top