Android DropBox Sync API问题

时间:2014-08-26 18:14:42

标签: android dropbox-api

所以我想在我的应用程序中实现dropbox sync API。我正在关注官方Dropbox教程中的代码:

static final int REQUEST_LINK_TO_DBX = 0;  // This value is up to you

public void onClickLinkToDropbox(View view) {
    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) {
            // ... Start using Dropbox files.
        } else {
            // ... Link failed or was cancelled by the user.
        }
    } else {
        super.onActivityResult(requestCode, resultCode, data);
    }
}

每当我运行我的应用程序并尝试单击按钮触发它时,我会收到以下错误:

Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.dropbox.sync.android.DbxAccountManager.startLink(android.app.Activity, int)' on a null object reference

知道为什么(Activity)返回null或者我如何更好地引用当前上下文?

0 个答案:

没有答案