To make things as easy as possible, we have several platform SDKs you can import into your development environment to get up and running quickly. The SDKs contain platform-specific libraries that wrap the raw HTTP calls to the Dropbox API. They are designed to shorten the distance between your application and integrating Dropbox.
Download and uncompress the latest version of the Android SDK. You'll need to include all of the JAR files from the lib folder on your project's build path. To make things especially easy, there is also a sample application in the examples/DBRoulette/ folder included with the Android SDK.
If you haven't already, first follow the steps at Google's Android SDK installation guide. We should note that Google's de facto development environment is Eclipse, so we'll also be using Eclipse for these instructions.
DBRoulette is a very basic Android app that authenticates and then loads a random photo from your Dropbox's Photos folder. You can import the DBRoulette sample project into Eclipse by going to the Import dialog, found in the File menu or by right-clicking in the Eclipse package explorer. Click General → Existing Projects and select the folder containing DBRoulette. Make sure you've updated to the latest version of Android Developer Tools for Eclipse.
You'll need to edit the code to enter your app key and secret where indicated in the AndroidManifest.xml and DBRoulette.java files (look for CHANGE_ME
).
The Eclipse project bundled with DBRoulette automatically targets the Android 1.5 platform. If you didn't download the Android 1.5 package when you first ran the AVD Manager, you'll have to specify your Android target platform in your project's preferences. Check the box next to the Android platform you are targeting.
Now try running the app to ensure it works. Feel free to use this Eclipse project as a template for your new project or read on to incorporate the SDK into your existing project by hand. If you do start up a new project, make sure to use a different app key and secret or uninstall DBRoulette from your device.
You'll need to get your app key and secret from the options page of your App Console. Once you have the app keys, we'll need to enter the following snippet in your AndroidManifest.xml in order for the Dropbox SDK to finish the authentication process. Insert the following code under the <application>
section, replacing INSERT_APP_KEY
with your app key:
<activity android:name="com.dropbox.client2.android.AuthActivity" android:launchMode="singleTask" android:configChanges="orientation|keyboard"> <intent-filter> <!-- Change this to be db- followed by your app key --> <data android:scheme="db-INSERT_APP_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>
Also make sure that your app has the internet permission by ensuring you have the following under the <manifest>
section of AndroidManifest.xml:
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
It's time to import all the Dropbox libraries and dependencies in the lib folder into your Eclipse project. To add the libraries to your build path, perform the following actions in Eclipse:
Once you save your preferences, you'll find that you can expand the libraries from the package explorer and browse the classes of the Dropbox SDK. You'll also get Javadoc in the Eclipse auto-complete pop-ups.
Now you're all set to start interacting with Dropbox.