Skip to content

Commit f731820

Browse files
Josh ZanaKannan Goundan
authored andcommitted
Add Android example.
1 parent b7c3796 commit f731820

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+1515
-3
lines changed

ReadMe.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ Save the API key to a JSON file called, say, "test.app":
4343
## Using the Dropbox API
4444

4545
Before your app can access a Dropbox user's files, the user must authorize your application using OAuth 2. Successfully completing this authorization flow gives you an _access token_ for the user's Dropbox account, which grants you the ability to make Dropbox API calls to access their files.
46-
47-
* Authorization example for a simple web app: [Web File Browser example](examples/web-file-browser/src/com/dropbox/core/examples/web_file_browser/DropboxAuth.java)
48-
* Authorization example for a command-line tool: [Command-Line Authorization example](examples/authorize/src/com/dropbox/core/examples/authorize/Main.java)
46+
* Example for a simple web app: [Web File Browser example](examples/web-file-browser/src/com/dropbox/core/examples/web_file_browser/DropboxAuth.java)
47+
* Example for an Android app: [Android example](examples/android/src/main/java/com/dropbox/core/examples/android/UserActivity.java)
48+
* Example for a command-line tool: [Command-Line Authorization example](examples/authorize/src/com/dropbox/core/examples/authorize/Main.java)
4949

5050
Once you have an access token, create a [`DbxClientV2`](https://dropbox.github.io/dropbox-sdk-java/api-docs/v2.0.x/com/dropbox/core/v2/DbxClientV2.html) and start making API calls.
5151

examples/android/.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/local.properties
2+
3+
/.gradle
4+
/build
5+
6+
/.idea
7+
/android.iml
8+
/captures

examples/android/ReadMe.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Example Android application (using the Dropbox SDK for Java.)
2+
3+
This shows the Dropbox API authorization flow and some API calls to retrieve files.
4+
5+
## Running the example
6+
7+
Prerequisites: Apache Maven (to build the SDK), [Android Studio](http://developer.android.com/sdk/installing/) (not strictly necessary)
8+
9+
1. Download this repository.
10+
2. Build the SDK: run `mvn package` in the SDK root directory (two levels up from this folder).
11+
3. In Android Studio, choose "Import Project" and select this folder.
12+
4. Edit "src/main/AndroidManifest.xml" and "src/main/res/values/strings.xml" and replace `YOUR_APP_KEY_HERE` with your Dropbox API key ([how to get a Dropbox API key](../../ReadMe.md#get-a-dropbox-api-key)).
13+
5. Build and run.
14+
15+
If you don't have Android Studio, you can use the command-line:
16+
17+
1. Make sure you have the standalone [Android SDK Tools](http://developer.android.com/sdk/installing/).
18+
2. Make sure your `ANDROID_SDK` environment variable is set to the path where the standalone Android SDK Tools are installed.
19+
3. To build: run `./gradlew assemble`.
20+
4. The example app's ".apk" files should now be in "build/outputs/apk". You can use "adb install" to install them to the emulator or to a real device.

examples/android/build.gradle

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
// Top-level build file where you can add configuration options common to all sub-projects/modules.
2+
3+
buildscript {
4+
repositories {
5+
jcenter()
6+
}
7+
dependencies {
8+
classpath 'com.android.tools.build:gradle:1.2.3'
9+
10+
// NOTE: Do not place your application dependencies here; they belong
11+
// in the individual module build.gradle files
12+
}
13+
}
14+
15+
allprojects {
16+
repositories {
17+
jcenter()
18+
mavenLocal()
19+
}
20+
}
21+
22+
apply plugin: 'com.android.application'
23+
24+
android {
25+
compileSdkVersion 22
26+
buildToolsVersion "22.0.1"
27+
28+
defaultConfig {
29+
applicationId "com.dropbox.core.examples.android"
30+
minSdkVersion 19
31+
targetSdkVersion 22
32+
versionCode 1
33+
versionName "1.0"
34+
}
35+
buildTypes {
36+
release {
37+
minifyEnabled false
38+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
39+
}
40+
}
41+
42+
packagingOptions {
43+
exclude 'META-INF/LICENSE'
44+
exclude 'META-INF/LICENSE.txt'
45+
exclude 'META-INF/NOTICE'
46+
exclude 'META-INF/NOTICE.txt'
47+
}
48+
}
49+
50+
dependencies {
51+
compile group: 'com.dropbox.core', name: 'dropbox-core-sdk', version: '0-SNAPSHOT', changing: true
52+
compile 'com.android.support:appcompat-v7:22.2.0'
53+
compile 'com.android.support:design:22.2.0'
54+
compile 'com.android.support:recyclerview-v7:21.0.0'
55+
compile 'com.fasterxml.jackson.core:jackson-core:2.5.4'
56+
compile 'com.fasterxml.jackson.core:jackson-annotations:2.5.4'
57+
compile 'com.squareup.picasso:picasso:2.5.2'
58+
compile 'com.squareup.okhttp:okhttp:2.4.0'
59+
}

examples/android/gradle.properties

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Project-wide Gradle settings.
2+
3+
# IDE (e.g. Android Studio) users:
4+
# Gradle settings configured through the IDE *will override*
5+
# any settings specified in this file.
6+
7+
# For more details on how to configure your build environment visit
8+
# http://www.gradle.org/docs/current/userguide/build_environment.html
9+
10+
# Specifies the JVM arguments used for the daemon process.
11+
# The setting is particularly useful for tweaking memory settings.
12+
# Default value: -Xmx10248m -XX:MaxPermSize=256m
13+
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14+
15+
# When configured, Gradle will run in incubating parallel mode.
16+
# This option should only be used with decoupled projects. More details, visit
17+
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18+
# org.gradle.parallel=true
48.7 KB
Binary file not shown.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#Wed Apr 10 15:27:10 PDT 2013
2+
distributionBase=GRADLE_USER_HOME
3+
distributionPath=wrapper/dists
4+
zipStoreBase=GRADLE_USER_HOME
5+
zipStorePath=wrapper/dists
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip

examples/android/gradlew

Lines changed: 164 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/android/gradlew.bat

Lines changed: 90 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)