Accessing google calendar through Android using the given protocol

by Nikhil Agarwal » Thu, 21 Jan 2010 19:10:16 GMT


Sponsored Links
 I need to insert,update,delete events in google calendar using
android. I tried using the gdata calendar protocol directly from
 http://code.google.com/apis/calendar/data/2.0/developers_guide_protocol.html 
but I could not go beyond authenticating the user.

I was able to authenticate the user and I extracted the Auth code
using:-

temp1 = EntityUtils.toString(response.getEntity());
if(response.getStatusLine().getStatusCode()==200)
                auth = temp1.substring(temp1.indexOf("Auth=")+5).trim
();

After this I tried inserting an event which did not work. I was
getting status code 200 in response and I am not sure even if I did
get a proper response, how can I extract the cookie s and gsessionid
for my next request.

I tried creating a calendar instead and I received the same status
code 200. I used the following code:-

   String messageBody="<entry xmlns=' http://www.w3.org/2005/Atom '"+
       " xmlns:gd=' http://schemas.google.com/g/2005 '"+
       " xmlns:gCal=' http://schemas.google.com/gCal/2005 '>"+
  " <title type='text'>SMS Invite Schedule</title>"+
  " <summary type='text'>This calendar contains the practice schedule
and game times.</summary>"+
  " <gCal:timezone value='Singapore/Asia'></gCal:timezone>"+
  " <gCal:hidden value='false'></gCal:hidden>"+
  " <gCal:color value='#2952A3'></gCal:color>"+
  " <gd:where rel='' label='' valueString='Oakland'></gd:where>"+
" </entry>";
 StringEntity entity =new StringEntity(messageBody);
            entity.setContentType("application/atom+xml");
            entity.setChunked(true);
            httppost.setEntity(entity);
            httppost.setHeader("Authorization", "GoogleLogin
auth="+auth);
            httppost.setHeader("GData-Version", "2");
            //httppost.setHeader("Content-Length",String.valueOf
(entity.getContentLength()));
            //httppost.setHeader("Content-Type", "application/atom
+xml");
            HttpResponse response = httpclient.execute(httppost);

As can be seen from the code, I commented Content-Length and Content-
Type as otherwise I would get a ClientProtocolException (content-
length was causing the exception, didn't put content-type since it is
already mentioned in the entity...not sure where it should be
defined).

I am sorry that I don't understand the basics correctly. I did refer
to the apache site for httpclient stuff but it wasn't of much help.
Please help me out with the above problems.  Thank you.



Accessing google calendar through Android using the given protocol

by Nikhil Agarwal » Thu, 21 Jan 2010 19:18:52 GMT


 I need to insert,update,delete events in google calendar using
android. I tried using the protocol given at
 http://code.google.com/apis/calendar/data/2.0/developers_guide_protocol.html 
but I was unable to go beyond authenticating the user.

I was able to authenticate the user and I extracted the Auth code
using:-
 temp1 = EntityUtils.toString(response.getEntity());
if(response.getStatusLine().getStatusCode()==200)
                auth = temp1.substring(temp1.indexOf("Auth=")+5).trim
();

After this I tried inserting an event which did not work. I was
getting status code 200 in response and I am not sure even if I did
get a proper response, how can I extract the cookie s and gsessionid
for my next request.

I tried creating a calendar instead and I received the same status
code 200. I used the following code:-

   String messageBody="<entry xmlns=' http://www.w3.org/2005/Atom '"+
       " xmlns:gd=' http://schemas.google.com/g/2005 '"+
       " xmlns:gCal=' http://schemas.google.com/gCal/2005 '>"+
  " <title type='text'>ABC Project Schedule</title>"+
  " <summary type='text'>This calendar...</summary>"+
  " <gCal:timezone value='Singapore/Asia'></gCal:timezone>"+
  " <gCal:hidden value='false'></gCal:hidden>"+
  " <gCal:color value='#2952A3'></gCal:color>"+
  " <gd:where rel='' label='' valueString='Oakland'></gd:where>"+
" </entry>";
 StringEntity entity =new StringEntity(messageBody);
            entity.setContentType("application/atom+xml");
            entity.setChunked(true);
            httppost.setEntity(entity);
            httppost.setHeader("Authorization", "GoogleLogin
auth="+auth);
            httppost.setHeader("GData-Version", "2");
            //httppost.setHeader("Content-Length",String.valueOf
(entity.getContentLength()));
            //httppost.setHeader("Content-Type", "application/atom
+xml");
            HttpResponse response = httpclient.execute(httppost);

As can be seen from the code, I commented Content-Length and Content-
Type as otherwise I would get a ClientProtocolException (content-
length was causing the exception, didn't put content-type since it is
already mentioned in the entity...not sure where it should be
defined).

I am sorry that I don't understand the basics correctly. I did refer
to the apache site for httpclient stuff but it wasn't of much help.
Please help me out with the above problems. It is very important for
my Android application to have this functionality. Thank you.


Sponsored Links


Accessing google calendar through Android using the given protocol

by Nikhil Agarwal » Thu, 21 Jan 2010 19:22:19 GMT


 I need to insert,update,delete events in google calendar using
android. I tried using the protocol given at
 http://code.google.com/apis/calendar/data/2.0/developers_guide_protoc... 
but I was unable to go beyond authenticating the user.

I was able to authenticate the user and I extracted the Auth code
using:-
 temp1 = EntityUtils.toString(response.getEntity());
if(response.getStatusLine().getStatusCode()==200)
                auth = temp1.substring(temp1.indexOf("Auth=")+5).trim
();

After this I tried inserting an event which did not work. I was
getting status code 200 in response and I am not sure even if I did
get a proper response, how can I extract the cookie s and gsessionid
for my next request.

I tried creating a calendar instead and I received the same status
code 200. I used the following code:-

   String messageBody="<entry xmlns=' http://www.w3.org/2005/Atom '"+
       " xmlns:gd=' http://schemas.google.com/g/2005 '"+
       " xmlns:gCal=' http://schemas.google.com/gCal/2005 '>"+
  " <title type='text'>ABC Project Schedule</title>"+
  " <summary type='text'>This calendar...</summary>"+
  " <gCal:timezone value='Singapore/Asia'></gCal:timezone>"+
  " <gCal:hidden value='false'></gCal:hidden>"+
  " <gCal:color value='#2952A3'></gCal:color>"+
  " <gd:where rel='' label='' valueString='Lab'></gd:where>"+
" </entry>";
 StringEntity entity =new StringEntity(messageBody);
            entity.setContentType("application/atom+xml");
            entity.setChunked(true);
            httppost.setEntity(entity);
            httppost.setHeader("Authorization", "GoogleLogin
auth="+auth);
            httppost.setHeader("GData-Version", "2");
            //httppost.setHeader("Content-Length",String.valueOf
(entity.getContentLength()));
            //httppost.setHeader("Content-Type", "application/atom
+xml");
            HttpResponse response = httpclient.execute(httppost);

As can be seen from the code, I commented Content-Length and Content-
Type as otherwise I would get a ClientProtocolException (content-
length was causing the exception, didn't put content-type since it is
already mentioned in the entity...not sure where it should be
defined).

I am sorry that I don't understand the basics correctly. I did refer
to the apache site for httpclient stuff but it wasn't of much help.
Please help me out with the above problems.  Thank you.



Other Threads

1. OnClickListener in my ListView

How do I add a listner to the list... please show with code

=======
JAVA
=======
public class VelgKomponent extends ListActivity implements
OnClickListener{
        String[] listItems = { "exploring", "android", "list", "activities",
"1",
                        "2", "3", "4" };

        @Override
        public void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
                setContentView(R.layout.velgkomp);
                setListAdapter(new ArrayAdapter<String>(this,
                                android.R.layout.simple_list_item_1, 
listItems));
                getListView().setTextFilterEnabled(true);
//
findViewById(android.R.layout.simple_list_item_1).setOnClickListener(this);

                Button bTilbake = (Button) findViewById(R.id.bTilbake);
                bTilbake.setOnClickListener(this);
        }

        @Override
        public void onClick(View v) {
                Intent intent = new Intent(v.getContext(), 
ShoppingBasket.class);
                startActivity(intent);
        }
}

========
XML
========
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/
android"
        android:orientation="vertical" android:layout_width="fill_parent"
        android:layout_height="fill_parent">
        <LinearLayout android:id="@+id/LinearLayout01"
                android:layout_height="wrap_content"
android:layout_width="fill_parent">
                <Button android:layout_width="wrap_content"
                        android:layout_height="wrap_content" 
android:layout_weight="1"
                        android:text="Tilbake" 
android:id="@+id/bTilbake"></Button>
                <TextView android:id="@+id/TextView01"
android:layout_width="wrap_content"
                        android:layout_height="wrap_content" 
android:layout_weight="1"
                        android:text="Velg komposisjon" 
android:gravity="center"></
TextView>
                <Button android:id="@+id/Button02"
android:layout_width="wrap_content"
                        android:layout_height="wrap_content" 
android:layout_weight="1"
                        android:text="Endre"></Button>
        </LinearLayout>
        <LinearLayout android:id="@+id/LinearLayout03"
                android:layout_weight="1" android:layout_width="fill_parent"
                android:layout_height="fill_parent">
                <ListView android:id="@android:id/list"
android:layout_width="fill_parent"
                        android:layout_weight="1" 
android:layout_height="fill_parent"></
ListView>
        </LinearLayout>
        <LinearLayout android:id="@+id/LinearLayout02"
                android:layout_height="wrap_content"
android:layout_width="fill_parent">
                <TextView android:text="Dette er en test "
                        android:layout_width="fill_parent"
android:layout_height="fill_parent" />
        </LinearLayout>
</LinearLayout>


-- 

2. Android Device Seeding Program - Differences in phone for developers?

Why? I visited a Google Technology Usergroup meeting where Google
handed out Nexus phones to all visitors, and they were identical to
the one that I had ordered from their online store.







-- 

3. G bisa download d market

4. Adding new XML file under layout

5. Switching views with RadioButton and saving views in Bundle

6. need help regarding map activity--showing blank graph with zoom control only no location view

7. Logout gmail?