android - 如何修复向 Google 日历添加事件时出现的 "Error connecting with login URI"异常?

标签 android google-calendar-api

我在 Java 中使用以下代码。它运行良好,并将事件添加到 Google 日历中。但在 Android 中,它会给出异常 Error connecting with login URI。谁能帮我解决这个问题?

CalendarService myService = new CalendarService("calendarTest");
String userName = "mytest.test@gmail.com";
String userPassword = "xxxxxxx";

// Create the necessary URL objects.
try {
    metafeedUrl = new URL(METAFEED_URL_BASE + userName);
    eventFeedUrl = new URL(METAFEED_URL_BASE + userName
        + EVENT_FEED_URL_SUFFIX);
} catch (MalformedURLException e) {
    // Bad URL
    strbuf.append(e.getMessage());
    System.err.println("Uh oh - you've got an invalid URL.");
    e.printStackTrace();
    return;
}

try
{
    myService.setUserCredentials(userName, userPassword);
    // Demonstrate creating a single-occurrence event.
    CalendarEventEntry singleEvent = createSingleEvent(myService,"Event Title", "Event Description "); 
    System.out.println("Successfully created event " +singleEvent.getTitle().getPlainText() );

    // Demonstrate creating a quick add event.
    CalendarEventEntry quickAddEvent = createQuickAddEvent(myService,"Tennis with me June 22 3pm-3:30pm");
    System.out.println("Successfully created quick add event "       + quickAddEvent.getTitle().getPlainText());

}
// catch.......

最佳答案

这需要互联网访问才能向日历添加内容,对吗?

所以你需要给你的应用程序访问互联网的权限。尝试在 AndroidManifest.xml 的结束标记之前添加:

<uses-permission android:name="android.permission.INTERNET"></uses-permission>

关于android - 如何修复向 Google 日历添加事件时出现的 "Error connecting with login URI"异常?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3069757/

相关文章:

android - Google Cast SDK RemoteMediaPlayer 网络视频转换,例如YouTube

php - JSON 编码返回相同类型

ios - 快速添加谷歌日历事件

https - Google 日历无法通过 https 订阅 icalendar 提要?

android - "only const val can be used in constant expressions"编译时错误 Dagger2 Kotlin

java - URL - Android 中图像文件的 FileNotFoundException

google-calendar-api - 如何通过直接链接将 WebCal/iCalendar 添加到 Google 日历

javascript - 谷歌日历 api - gd$where 的输出未定义

oauth - 谷歌日历 API 错误 - "API key not valid. Please pass a valid API key.",

java - android 将 String 数组和 String 传递给 asyncTask