To shorten the URL using google api
<p>Hi i am using an example to make a url shorten. But cant able to do that, here's my code</p>

<pre><code>package com.tinyurl;
import java.io.IOException;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import com.google.api.client.googleapis.GoogleHeaders;
import com.google.api.client.googleapis.GoogleTransport;
import com.google.api.client.http.HttpRequest;
import com.google.api.client.http.HttpResponse;
import com.google.api.client.http.HttpTransport;
import com.google.api.client.json.GenericJson;
import com.google.api.client.json.JsonHttpContent;
import com.google.api.client.json.JsonHttpParser;
import com.google.api.client.util.GenericData;
public class tinyurl extends Activity implements OnClickListener {
EditText original;
TextView txt;

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    Button btn = (Button) findViewById(R.id.Button01);

    original = (EditText) findViewById(R.id.edittext);
    txt = (TextView) findViewById(R.id.TextView03);
    btn.setOnClickListener(this);
}


@Override
public void onClick(View v) {

    final String GOOGL_URL = "https://www.googleapis.com/urlshortener/v1/url?key=AIzaSyAau1E_WrYwMiTNqhK5hgH0tyWudyahbOI";
    String tinyUrl = null;
    String original = "http://www.google.com/";
    HttpTransport transport = GoogleTransport.create();
    GoogleHeaders defaultHeaders = new GoogleHeaders();
    transport.defaultHeaders = defaultHeaders;
    transport.defaultHeaders.put("Content-Type", "application/json");
    transport.addParser(new JsonHttpParser());
    HttpRequest request = transport.buildPostRequest();
    request.setUrl(GOOGL_URL);
    GenericData data = new GenericData();
    // data.put("longUrl", "http://www.google.com/");
    data.put("longUrl", original);
    JsonHttpContent content = new JsonHttpContent();

    content.data = data;
    request.content = content;

    HttpResponse response = null;
    try {
        response = request.execute();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        Log.d("eception occured", e.toString());
    }
    Result result = null;
    try {
        result = response.parseAs(Result.class);
        Log.d("TinyUrl", result.shortUrl.toString());
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

}

public class Result extends GenericJson {

    public String shortUrl;

}
</code></pre>

<p>}</p>

<p>but the thing is i am getting in Log is java.net.UnknownHostException:www.googleapis.com</p>
