Thursday, July 14, 2011

[android-developers] Google Calendar APIs for the android

I want in webview to push a button on my webpage and add an event to
the google calendar on the android phone.
Trouble is I get pointed to Google Calendar APIs webpage and it has no
examples or tutorials on this.

I learn by example and cannot translate this to the android. I need
an example or tutorial.

Can someone please help?. This is what I have so far.

public class button7 extends Activity{

WebView wb = null;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.buttons);
wb = new WebView(this);
wb.setWebViewClient(new HelloWebViewClient());
wb.getSettings().setJavaScriptEnabled(true);
wb.loadUrl("http://www.whatever website.com");
setContentView(wb);
}

private class HelloWebViewClient extends WebViewClient {

public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
SetCalenderEntry(1,"Test","Is this working","At home");
return true;
}

}


private void SetCalenderEntry(int i, String subject, String body,
String location)
{
ContentValues event = new ContentValues();
event.put("calendar_id", i);
event.put("title", subject);
event.put("description", body);
event.put("eventLocation", location);
long startTime = System.currentTimeMillis() + 1000 * 60 * 60;
long endTime = System.currentTimeMillis() + 1000 * 60 * 60 * 2;
event.put("dtstart", startTime);
event.put("dtend", endTime);
Uri eventsUri = Uri.parse("content://calendar/events");
getContentResolver().insert(eventsUri, event);
}

public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK && wb.canGoBack())
wb.goBack();
return super.onKeyDown(keyCode, event);
}
}

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment