android - Dropbox Sync API startLink() method not working -


i'm developing android app uses dropbox sync api upload files. have created app on dropbox, gotten app_key , app_secret. have included necessary libraries, set proper keys in activity code , manifest. app similar hellodropbox sample provided in documentation, when click on "link dropbox" button supposed display place enter dropbox credentials, nothing happens. here's source code:

package com.diamondtrust66.helix.player; import java.io.file; import java.io.ioexception; import java.util.list;  import android.app.activity; import android.content.intent; import android.os.bundle; import android.view.view; import android.view.view.onclicklistener; import android.widget.button; import android.widget.textview; import android.widget.toast;  import com.dropbox.client2.dropboxapi; import com.dropbox.sync.android.dbxaccountmanager; import com.dropbox.sync.android.dbxfile; import com.dropbox.sync.android.dbxfileinfo; import com.dropbox.sync.android.dbxfilesystem; import com.dropbox.sync.android.dbxpath;  public class helixplayer extends activity {  private static final string appkey = "1234-my-key"; private static final string appsecret = "1234-my-secret";  private static final int request_link_to_dbx = 0;  private textview mtestoutput; private button mlinkbutton; private dbxaccountmanager mdbxacctmgr; private dropboxapi<?> mdbapi;  @override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_helix_player);     mtestoutput = (textview) findviewbyid(r.id.test_output);     mlinkbutton = (button) findviewbyid(r.id.link_button);     mlinkbutton.setonclicklistener(new onclicklistener() {         @override         public void onclick(view v) {             onclicklinktodropbox();         }     });      mdbxacctmgr = dbxaccountmanager.getinstance(getapplicationcontext(), appkey, appsecret); }  @override protected void onresume() {     super.onresume();     if (mdbxacctmgr.haslinkedaccount()) {         showlinkedview();         dodropboxtest();     } else {         showunlinkedview();     } }  private void showlinkedview() {     mlinkbutton.setvisibility(view.gone);     mtestoutput.setvisibility(view.visible); }  private void showunlinkedview() {     mlinkbutton.setvisibility(view.visible);     mtestoutput.setvisibility(view.gone); }  private void onclicklinktodropbox() {     mdbxacctmgr.startlink((activity)this, request_link_to_dbx); }  @override public void onactivityresult(int requestcode, int resultcode, intent data) {     if (requestcode == request_link_to_dbx) {         if (resultcode == activity.result_ok) {             dodropboxtest();         } else {             toast.maketext(getapplicationcontext(), "failure", toast.length_long).show();             mtestoutput.settext("link dropbox failed or cancelled.");         }     } else {         super.onactivityresult(requestcode, resultcode, data);     } }  private void dodropboxtest() {     try {         final string test_data = "hello dropbox";         final string test_file_name = "be that.mp3";         dbxpath testpath = new dbxpath(dbxpath.root, test_file_name);          // create dbxfilesystem synchronized file access.         dbxfilesystem dbxfs = dbxfilesystem.foraccount(mdbxacctmgr.getlinkedaccount());              // print contents of root folder.  block until can         // sync metadata first time.         list<dbxfileinfo> infos = dbxfs.listfolder(dbxpath.root);         mtestoutput.settext("\ncontents of app folder:\n");         (dbxfileinfo info : infos) {             mtestoutput.append("    " + info.path + ", " + info.modifiedtime + '\n');         }          // create test file if doesn't exist.         if (!dbxfs.exists(testpath)) {             dbxfile testfile = dbxfs.create(testpath);             try {                  file myfile = new file("/mnt/sdcard/alarms/be that.mp3");                 //testfile.writestring(test_data);                 testfile.writefromexistingfile(myfile, false);             } {                 testfile.close();             }             mtestoutput.append("\ncreated new file '" + testpath + "'.\n");         }          // read , print contents of test file.  since we're not making         // attempt wait latest version, may print         // older cached version.  use getsyncstatus() and/or listener         // check new version.         /*if (dbxfs.isfile(testpath)) {             string resultdata;             dbxfile testfile = dbxfs.open(testpath);             try {                 resultdata = testfile.readstring();             } {                 testfile.close();             }             mtestoutput.append("\nread file '" + testpath + "' , got data:\n    " + resultdata);         } else if (dbxfs.isfolder(testpath)) {             mtestoutput.append("'" + testpath.tostring() + "' folder.\n");         }*/     } catch (ioexception e) {         mtestoutput.settext("dropbox test failed: " + e);     } } 

}

are able run unmodified hello dropbox example on same emulator/device you're experiencing problem? can try replacing app key/secret in sample own well. if fail, may there's wrong configuration of device keeping api launching browser complete authentication. if example works, app doesn't, i'd suspect misconfigured there. can check log statement whether call startlink() happening? see appear in logcat after point?

the best way debug further might open suppot ticket. use api support link here: https://www.dropbox.com/developers


Comments