hi ,

i have got a problem not to test google calendarTest code.

i don't know where to go those things (JakartaGDataClient ,
AndroidXmlParserFactory, XmlCalendarGDataParserFactory ,... etc)
These was in gData API of M5 version, but where are these now?

this is the code that i've attempted.

http://androidlbs.googlecode.com/svnhistory/r21/SampleCalendar/src/org/sample/CalendarDemo/CalendarTest.java

< sniffet of source >

package org.sample.CaledarDemo;

import com.google.android.gdata.client.AndroidXmlParserFactory;
import com.google.android.gdata.client.JakartaGDataClient;
import com.google.wireless.gdata.calendar.client.CalendarClient;
import com.google.wireless.gdata.calendar.data.EventEntry;
import com.google.wireless.gdata.calendar.data.When;
import
com.google.wireless.gdata.calendar.parser.xml.XmlCalendarGDataParserFactory;
import com.google.wireless.gdata.client.QueryParams;
import com.google.wireless.gdata.data.Feed;
import com.google.wireless.gdata.parser.GDataParser;

@SuppressWarnings("unused")
public class CalendarTest extends Activity implements
View.OnClickListener  {

    public void onClick(View view) {
        XmlCalendarGDataParserFactory factory = new
XmlCalendarGDataParserFactory(new AndroidXmlParserFactory());
        XmlParser parser = new XmlParser();

        JakartaGDataClient dataClient = new JakartaGDataClient();
        String strFromTime =  "";
        String strToTime =  "";

        // Generate the URL for a private ATOM feed in google calendar
        String url = "http://www.google.com/calendar/feeds/"; +
                Uri.encode(mUserId.getText().toString()) + "/private/
full";
        QueryParams params = dataClient.createQueryParams();
        String pad1 = (mMonth + 1) < 10 ? "0" : "";
        String pad2 = mDay < 10 ? "0" : "";
        params.setParamValue(new DateTime(mYear + "-" + pad1 + (mMonth
+ 1) + "-" + pad2 + mDay + "T00:00:00"));
        params.setParamValue("start-max", mYear + "-" + pad1 + (mMonth
+ 1) + "-" + pad2 + mDay + "T23:59:59");
        url = params.generateQueryUrl(url);
        Log.i("GoogleContacts", "URL :" + url);

        CalendarClient client = new CalendarClient(dataClient,
factory, url);
        try {
            Log.i("GoogleContacts", "BaseFeedUrl:" +
client.getBaseFeedUrl());

            String user = mUserId.getText().toString();
            String password = mPassword.getText().toString();
            Log.i("GoogleContacts", "userid:" + user);
            Log.i("GoogleContacts", "password:" + password);

            // Get the google token
            String authToken = client.getAuthToken(user, password);
            Log.i("GoogleContacts", "Token:" + authToken);

            // Use the token and access the actual feed.
            java.io.InputStream is = dataClient.getFeedAsStream(url,
authToken);
            GDataParser parser = factory.createParser(is);
            Feed feed = parser.init();

            int totalResults = feed.getTotalResults();
            Log.i("GoogleContacts", "Results:" + totalResults);

            // wade thru the entries and pick interesting information
            EventEntry entry = null;
            String[] items = new String[totalResults];
            for (int i = 0; i < totalResults; i++) {
                entry = (EventEntry) parser.readNextEntry(entry);
                Log.i("GoogleContacts", "Entry ID:" + entry.getId());
                Log.i("GoogleContacts", "Entry Title:" + entry.getTitle
());
                Log.i("GoogleContacts", "Update Date:" +
entry.getFirstWhen().getStartTime().length());
                When when = entry.getFirstWhen();
                // check if the event has a specific time or is a day
event by validating with the length
                if(when.getStartTime().length() > 11 ){
                Date time1 = lngDateFormat.parse(when.getStartTime());
                Date time2 = lngDateFormat.parse(when.getEndTime());
                strFromTime =  shortDateFormat.format(time1);
                strToTime =  shortDateFormat.format(time2);
                }
                else
                {
                        strFromTime = when.getStartTime();
                        strToTime = when.getEndTime();
                }
                Log.i("GoogleContacts", "Date/Time: FROM " +
strFromTime + " TO " + strToTime);
                items[i] = strFromTime + " - " + strToTime + " : " +
entry.getTitle();
            }

            // Display the information in the list view
            ListView listView = (ListView) findViewById(R.id.data);
            listView.setAdapter(new ArrayAdapter(this,
                    android.R.layout.simple_list_item_1,
                    items));
        } catch (Exception e) {
            Log.e("GoogleContacts", e.toString(), e);
        }
    }
}

thanks your help~

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Calendar Data API" group.
To post to this group, send email to 
[email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/google-calendar-help-dataapi?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to