1
votes

I am trying to add an event to a Google Calendar in Android Studio. I have been trying to follow the steps at https://developers.google.com/google-apps/calendar/v3/reference/events/insert#request-body and https://developers.google.com/google-apps/calendar/quickstart/java for the Java example.

However I get the following runtime error when I run the app on my phone:

java.io.IOException: Unable to create the directory[credentials/calendar-java-quickstart.json]

Any ideas on why this might happen? This is sample code on the Google API pages for Java. Is there a different way of doing in android?

1
Isn't it just an intent to the calendar app? Oh, you don't mean the system calendar you mean the cloud calendar, correct? - MeetTitan
Yes, this is not for the Android Calendar on the phone, but for the Google Calendar in your Google Account. I managed to fetch data from it but I am not able to add events to it. - omarp
Do you have permissions to write to /home/username/credentials/calendar-java-quistart.json? - MeetTitan
I have: <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> on my manifest. Is this permission you are referring to? - omarp
You're on android? There's your problem, System.property("user.home") doens't return anything on android! You should look for an android example using android apis instead of using the vanilla java ones, you're making your life harder than it has to be. - MeetTitan

1 Answers

0
votes

I figured this out. For those interested, you shouldn't use the Java quickstart at https://developers.google.com/google-apps/calendar/quickstart/java. I just changed the service in the insert method to the mService defined in the Android QuickStart file and changed the permissions on Scope to Calendar instead of Calendar_ReadOnly.