从我的应用程序将事件添加到谷歌日历
我有代码。 eclipse中没有错误。但在模拟器中,我收到“应用程序已意外停止”错误。我做了很多研究,但我无法摆脱这个问题。我希望应用程序做的就是将事件添加到我的谷歌日历中。
代码片段:
public class HelloAndroid extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Set up the URL and the object that will handle the connection:
URL postUrl = null;
try {
postUrl = new URL("http://www.google.com/calendar/feeds/[email protected]/private/full");
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
CalendarService myService = new CalendarService("exampleCo-exampleApp-1");
try {
myService.setUserCredentials("xyz","xyz123");
} catch (AuthenticationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
EventEntry myEntry = new EventEntry();
myEntry.setTitle(new PlainTextConstruct("test event"));
myEntry.setContent(new PlainTextConstruct("Working!!"));
Person author = new Person("It's me", null, "[email protected]");
myEntry.getAuthors().add(author);
DateTime startTime = DateTime.parseDateTime("2011-07-20T15:00:00-08:00");
DateTime endTime = DateTime.parseDateTime("2011-07-20T17:00:00-08:00");
When eventTimes = new When();
eventTimes.setStartTime(startTime);
eventTimes.setEndTime(endTime);
myEntry.addTime(eventTimes);
try {
EventEntry insertedEntry = myService.insert (postUrl, myEntry);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ServiceException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
setContentView(R.layout.main);
}
与代码或清单有关吗?
I have the code. No errors in eclipse. But in the emulator, I'm getting "Application has stopped unexpectedly" error. I have done a lot of research but I'm not able to get rid of this. All I want the app to do is to add events to my google calendar.
The code snippet:
public class HelloAndroid extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Set up the URL and the object that will handle the connection:
URL postUrl = null;
try {
postUrl = new URL("http://www.google.com/calendar/feeds/[email protected]/private/full");
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
CalendarService myService = new CalendarService("exampleCo-exampleApp-1");
try {
myService.setUserCredentials("xyz","xyz123");
} catch (AuthenticationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
EventEntry myEntry = new EventEntry();
myEntry.setTitle(new PlainTextConstruct("test event"));
myEntry.setContent(new PlainTextConstruct("Working!!"));
Person author = new Person("It's me", null, "[email protected]");
myEntry.getAuthors().add(author);
DateTime startTime = DateTime.parseDateTime("2011-07-20T15:00:00-08:00");
DateTime endTime = DateTime.parseDateTime("2011-07-20T17:00:00-08:00");
When eventTimes = new When();
eventTimes.setStartTime(startTime);
eventTimes.setEndTime(endTime);
myEntry.addTime(eventTimes);
try {
EventEntry insertedEntry = myService.insert (postUrl, myEntry);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ServiceException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
setContentView(R.layout.main);
}
Is it anything to do with the code or the manifest?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论