Last active
December 21, 2015 13:49
-
-
Save rossmartin/6315147 to your computer and use it in GitHub Desktop.
phonegap-dropbox-sync AppMainActivity
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.rossmartin.dropbox; | |
import android.app.Activity; | |
import android.content.Intent; | |
import android.os.Bundle; | |
import android.util.Log; | |
import org.apache.cordova.*; | |
public class PhoneGapSync extends CordovaActivity | |
{ | |
private static final String TAG = "CordovaActivity"; | |
static final int REQUEST_LINK_TO_DBX = 1337; // This value is up to you, must be the same as in your plugin though | |
@Override | |
public void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
super.init(); | |
// Set by <content src="index.html" /> in config.xml | |
super.loadUrl(Config.getStartUrl()); | |
//super.loadUrl("file:///android_asset/www/index.html") | |
} | |
@Override | |
public void onActivityResult(int requestCode, int resultCode, Intent data) { | |
if (requestCode == REQUEST_LINK_TO_DBX) { | |
if (resultCode == Activity.RESULT_OK) { | |
// ... You can now start using Dropbox Sync API. | |
super.sendJavascript("dropbox_linked();"); | |
} else { | |
// ... Link failed or was cancelled by the user. | |
Log.v(TAG, "Dropbox link failed or was cancelled by the user."); | |
} | |
} else { | |
super.onActivityResult(requestCode, resultCode, data); | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment