Hello,
So first I removed from my android app all V1 API code.
I have an eclipse project. I added all .jar files for V2 API 3.0.3 and dependencies.
I looked at the example (which has no comments).
So for now i have just placed all authentication into my OnResume. But it crashes when executing DropboxClientFactory.init(accessToken);
I start the App, open the settings and enable dropbox, this then passes message MESSAGE_AUTHENTICATE_DROPBOX which implements Auth.startOAuth2Authentication(BluetoothChat.this, APP_KEY) and i get the AuthActivity and I authorise, then onResume gets the access token and then it closes.
if i step through with the debugger then when DropboxClientFactory.init(accessToken) is called the debugger jumps to super.onResume() and then the app closes.
Here is the onResume:-
@Override
public synchronized void onResume() {
super.onResume();
if(D) Log.e(TAG, "+ ON RESUME +");
boolean dropBoxState=Prefs_DropBox; //Save Dropbox Prefs State before reload prefs
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
String accessToken = prefs.getString("access-token", null);
if (accessToken == null) {
accessToken = Auth.getOAuth2Token();
if (accessToken != null) {
prefs.edit().putString("access-token", accessToken).apply();
prefs.edit().putBoolean("DropboxIntegration", true).commit();
DropboxClientFactory.init(accessToken);
PicassoClient.init(getApplicationContext(),com.dropbox.core.examples.android.DropboxClientFactory.getClient());
}
} else {
DropboxClientFactory.init(accessToken);
PicassoClient.init(getApplicationContext(), com.dropbox.core.examples.android.DropboxClientFactory.getClient());
}
if(D) Log.e(TAG, "LoadPrefs");
LoadPrefs();
if (Prefs_DropBox) {
if (!dropBoxState) //Dropbox has just been enabled
{
mHandler.obtainMessage(MESSAGE_AUTHENTICATE_DROPBOX).sendToTarget();
//Disable again until Authentication completes!
prefs.edit().putBoolean("DropboxIntegration", false).commit();
}
}