尝试连接到Dropbox API版本2

我试图通过Android Studio连接到Dropbox api版本2,但我得到这个异常:

04-27 23:49:33.356 6482-6482/com.example.user.trackyournevi 
E/AndroidRuntime: FATAL EXCEPTION: main                                                                              
Process: com.example.user.trackyournevi, PID: 6482                                                                                      
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.user.trackyournevi/com.example.user.trackyournevi.Drop
boxActivity}: android.content.ActivityNotFoundException: Unable to find 
explicit activity class 
{com.example.user.trackyournevi/com.dropbox.client2.android.AuthActivity}; 
have you declared this activity in your AndroidManifest.xml?

我的Dropbox活动:

    public class DropboxActivity extends AppCompatActivity implements 
    View.OnClickListener {

    private LinearLayout container;
    private boolean isUserLoggedIn;
    private Button btnLogin;
    private Button btnUpload;
    private Button btnDownload;

    private DropboxAPI<AndroidAuthSession> mDropboxApi;

    private final static String DROPBOX_FILE_DIR = "/TrackYourNevi/";
    private static final int IMAGE_GALLERY_REQUEST = 20;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
       setContentView(R.layout.activity_dropbox);

       loggedIn(false);
       //callback method
       initializeSession();
    }

    private void initializeSession() {
    //store app key and secret key
    AppKeyPair appKeys = new AppKeyPair(getResources().getString(R.string.DROPBOX_APP_KEY),
            getResources().getString(R.string.DROPBOX_APP_SECRET));
    AndroidAuthSession session = new AndroidAuthSession(appKeys);
    //Pass app key pair to new DropboxApi object
    mDropboxApi = new DropboxAPI<AndroidAuthSession>(session);
    //start session
    mDropboxApi.getSession().startOAuth2Authentication(DropboxActivity.this);
}

@Override
public void onResume() {
    super.onResume();
    if(mDropboxApi.getSession().authenticationSuccessful()) {
        try {
            // Required to complete auth, sets the access token on the session
            mDropboxApi.getSession().finishAuthentication();
            String accessToken = mDropboxApi.getSession().getOAuth2AccessToken();
            loggedIn(true);
        } catch (IllegalStateException e) {
            e.printStackTrace();
        }
    }
}

@Override
public void onClick(View v) {
    switch (v.getId()){
        case R.id.dxbLoginButton:
            if(isUserLoggedIn) {
                mDropboxApi.getSession().unlink();
                loggedIn(false);
            } else
                mDropboxApi.getSession().startOAuth2Authentication(DropboxActivity.this);
            break;
        case R.id.dxbUploadButton:
            //invoke the image gallery using an implict intent
            Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
            //Where do we want to find the data
            File pictureDirectory = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
            String pictureDitrectoryPath = pictureDirectory.getPath() + "/" + getResources().getString(R.string.image_folder_name);
            //Get URI representation
            Uri data = Uri.parse(pictureDitrectoryPath);
            //Set the data and type. get all images from jpg type
            photoPickerIntent.setDataAndType(data, "image/jpg");
            startActivityForResult(photoPickerIntent, IMAGE_GALLERY_REQUEST);
            break;
        case R.id.dxbDownloanButton:
            break;
        default:
            break;
    }
}

}

我的manifiest.xml包含以下数据:

    activity android:name=".DropboxActivity" android:launchMode="singleTask"
    intent-filter
        data android:scheme="db-key"
        action android:name="android.intent.action.VIEW"
        category android:name="android.intent.category.BROWSABLE"
        category android:name="android.intent.category.DEFAULT"
    intent-filter
    activity

它看起来像我在其他教程中看到的那样定义了一切,但仍然无法正常工作。 有人看到问题并能帮助我吗?

链接地址: http://www.djcxy.com/p/92951.html

上一篇: try to connect to Dropbox API version 2

下一篇: Android App can't deploy to virtual device