2
내 앱을 사용하여 캘린더에 새 일정을 추가하려고합니다. 나는 다음과 같은 코드를 사용캘린더에 일정을 추가하는 중 오류가 발생했습니다. 이름은 비워서는 안됩니다.
E/UncaughtException: java.lang.IllegalArgumentException: the name must not be empty: null
at android.accounts.Account.<init>(Account.java:48)
at com.google.android.gms.auth.zze.getToken(Unknown Source)
at com.google.android.gms.auth.GoogleAuthUtil.getToken(Unknown Source)
at com.google.api.client.googleapis.extensions.android.gms.auth.GoogleAccountCredential.getToken(GoogleAccountCredential.java:269)
at com.google.api.client.googleapis.extensions.android.gms.auth.GoogleAccountCredential$RequestHandler.intercept(GoogleAccountCredential.java:294)
at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:868)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:419)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:352)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:469)
at com.socialcar.booking_fragment.BookingOwnerDetailFragment.createEvent(BookingOwnerDetailFragment.java:456)
at com.socialcar.booking_fragment.BookingOwnerDetailFragment.onClick(BookingOwnerDetailFragment.java:299)
at android.view.View.performClick(View.java:4615)
at android.view.View$PerformClick.run(View.java:18784)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5061)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:787)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:603)
at dalvik.system.NativeStart.main(Native Method)
내가 해결책을 찾기 위해 다른 곳에서 확인하고 오류가 뭔가 잘못된 것 같다 :
public void createEvent() {
String token = preferences.getString(Config.GOOGLE_TOKEN, "");
m_credential = GoogleAccountCredential.usingOAuth2(this.getContext(), SCOPES);
m_credential.setSelectedAccountName(token);
HttpTransport transport = AndroidHttp.newCompatibleTransport();
JsonFactory jsonFactory = JacksonFactory.getDefaultInstance();
com.google.api.services.calendar.Calendar service = new com.google.api.services.calendar.Calendar.Builder(
transport, jsonFactory, m_credential)
.setApplicationName("R_D_Location Callendar")
.build();
Event event = new Event()
.setSummary("Event- April 2016")
.setLocation("Dhaka")
.setDescription("New Event 1");
DateTime startDateTime = new DateTime("2017-02-26T18:10:00+06:00");
EventDateTime start = new EventDateTime()
.setDateTime(startDateTime)
.setTimeZone("Asia/Dhaka");
event.setStart(start);
DateTime endDateTime = new DateTime("2017-02-26T18:40:00+06:00");
EventDateTime end = new EventDateTime()
.setDateTime(endDateTime)
.setTimeZone("Asia/Dhaka");
event.setEnd(end);
String[] recurrence = new String[]{"RRULE:FREQ=DAILY;COUNT=2"};
event.setRecurrence(Arrays.asList(recurrence));
EventAttendee[] attendees = new EventAttendee[]{
new EventAttendee().setEmail("[email protected]"),
new EventAttendee().setEmail("[email protected]"),
};
event.setAttendees(Arrays.asList(attendees));
EventReminder[] reminderOverrides = new EventReminder[]{
new EventReminder().setMethod("email").setMinutes(24 * 60),
new EventReminder().setMethod("popup").setMinutes(10),
};
Event.Reminders reminders = new Event.Reminders()
.setUseDefault(false)
.setOverrides(Arrays.asList(reminderOverrides));
event.setReminders(reminders);
String calendarId = "primary";
try {
event = service.events().insert(calendarId, event).execute();
} catch (IOException e) {
e.printStackTrace();
}
System.out.printf("Event created: %s\n", event.getHtmlLink());
}
그러나 event = service.events().insert(calendarId, event).execute();
라인에서 나는 다음과 같은 오류에 geting하고
해결책을 찾았습니까? – Kaushal28