开发者

Retrieving Google calendar list using gdata-android-2.2.1-alpha

I need a simple working example with all the relevant import. I found only one example but its too complicated and many imports are mi开发者_StackOverflow中文版ssing


Okay I've found a better solution I written this using HttpGet

    /***************************************************************************************************************************/
/*                        RETURNS Calendar List                                                                            */
/***************************************************************************************************************************/
//@param authKey, represents the token key ,Auth=......
public void calendarList(String authKey){ 

    HttpClient httpclient = new DefaultHttpClient();
    HttpGet httpget = new HttpGet("https://www.google.com/calendar/feeds/default/allcalendars/full");
    httpget.setHeader("Authorization","GoogleLogin "+authKey);


    // Execute HTTP Post Request
    org.apache.http.HttpResponse response; 
    try {
        response = httpclient.execute(httpget);
        HttpEntity httpEntity = response.getEntity();

        InputStream stream = httpEntity.getContent();
        BufferedReader reader = new BufferedReader(new InputStreamReader(stream));

        StringBuilder total = new StringBuilder();
        String line;
        while ((line = reader.readLine()) != null) {
            total.append(line);
            Log.d("RESPONSE LIST",line+"\n");                               
        }



    } catch (ClientProtocolException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜