• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Google api java client problem

pedjasmek

Newbie
Jan 14, 2011
21
0
I am trying to manipulate with my own google calendar but didn't get further from the attempt to add new event.I am using this classes :
/calendar-v2-atom-oauth-sample/src/com/google/ - google-api-java-client - Project Hosting on Google Code and this code also:
Code:
final AccountManager manager = AccountManager
						.get(getApplicationContext());
				final Account[] accounts = manager
						.getAccountsByType("com.google");
				final int size = accounts.length;
				String[] names = new String[size];
				for (int i = 0; i < size; i++) {
					names[i] = accounts[i].name;
					 AccountManagerFuture<Bundle> accountManagerFuture =
					 manager
					 .getAuthToken(accounts[i], "cl", true, null, null);
					 Bundle authTokenBundle;
					try {
						 authTokenBundle = accountManagerFuture.getResult();
						 boolean contains = authTokenBundle
						 .containsKey(AccountManager.KEY_AUTHTOKEN);
						 String authToken = authTokenBundle
						 .getString(AccountManager.KEY_AUTHTOKEN);
						HttpTransport transport = GoogleTransport.create();
						GoogleHeaders headers = (GoogleHeaders) transport.defaultHeaders;
						
						headers.gdataVersion = "2";
						AtomParser parser = new AtomParser();
						parser.namespaceDictionary = Namespace.DICTIONARY;
						transport.addParser(parser);
						


						((GoogleHeaders) transport.defaultHeaders)
								.setGoogleLogin(authToken);
						
						CalendarEntry calendar = new CalendarEntry();
						CalendarUrl url = CalendarUrl.forOwnCalendarsFeed(names[i]);//https://www.google.com/calendar/feeds/myemail/private/full
						

						
						EventEntry entry = new EventEntry();
						entry.title = "Proba";
						When when = new When();
						when.startTime = new DateTime(System
								.currentTimeMillis() + 10000);
						when.endTime = new DateTime(
								System.currentTimeMillis() + 50000000);
						entry.when = when;
						EventEntry result = entry.executeInsert(transport, url);
						System.out.println();
					} catch (IOException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					} catch (OperationCanceledException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					} catch (AuthenticatorException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
but I get http response code 302 temporarily moved.Any help?Thanks!
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones