Using CookieSyncManager

Tumblr has a mobile version of the user dashboard,, it can easily be embedded in mobile apps to remove the need to build a custom dashboard. In the tumblr api documentation they have a example in Objective-C:
NSString *email           = @"";
NSString *password        = @"password";
NSString *destination_url = @"/iphone";

NSMutableURLRequest *request = [[NSMutableURLRequest alloc]
    initWithURL:[NSURL URLWithString:@""]
[request setHTTPMethod:@"POST"];
NSString *request_body = [NSString
    [email           stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],
    [password        stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],
    [destination_url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]
[request setHTTPBody:[request_body dataUsingEncoding:NSUTF8StringEncoding]];
/* Load the request here with an NDA-covered iPhone component
   that can view the web.
[request release];
Since I build Android applications I had to port the basic function. What I had to do was to authenticate using a DefaultHttpClient and get the cookies the server returns for me to set, then use those cookies when I load a WebView with the dashboard URL. This was I can avoid the login page and just send the user to the dashboard.
public List authenticateAndReturnCookies() {
		DefaultHttpClient httpclient = new DefaultHttpClient();
		HttpPost httppost = new HttpPost("");

		try {
			List nameValuePairs = new ArrayList(2);
			nameValuePairs.add(new BasicNameValuePair("email", getUserName()));
					.add(new BasicNameValuePair("password", getPassword()));
			httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));


			return httpclient.getCookieStore().getCookies();
		} catch (ClientProtocolException e) {
		} catch (IOException e) {

		return null;
To be able to sync cookies you need to create a instance of the CookieSyncManager, after that it's just to take the cookies that was returned from login and set them on the CookiesSyncManager instance. Once that is done the cookies can be used in a WebView. In my case since the cookies are set the iPhone dashboard works and I don't end up at the login page.
public void onCreate(Bundle savedInstanceState) {

		webView = new WebView(this);

private void setupCookies() {
		TumblrApi api = new TumblrApi(this);
		List cookies = api.authenticateAndReturnCookies();

		if (cookies != null) {
			for (Cookie cookie : cookies) {
				String cookieString = cookie.getName() + "="
						+ cookie.getValue() + "; domain=" + cookie.getDomain();
The only thing here, they really should have named the URL mobile and not iPhone :) The full implementation for this can be found in the ttTumblr repository on github.