1
votes

I am trying to access the Google Calendar events of a specific Google account form Android Things 0.6.1.

Unfortunately I cannot use the Android Calendar API because Android Things as no Google account linked to it, like a normal Android device, nor a user interface that can be used to select the account and grant the the permission.

I tried to use the plain Java Calendar API, but on Android Things is failing due to a JVM incompatibility when I try to authenticate:

Caused by: java.lang.ClassNotFoundException: Didn't find class "java.awt.Desktop" on path: DexPathList[[zip file "/system/framework/com.google.android.things.jar", zip file "/data/app/com.leinardi.android.things.deskclock-sFpdt1rVzS8n7goWxN7dFA==/base.apk"],nativeLibraryDirectories=[/data/app/com.leinardi.android.things.deskclock-sFpdt1rVzS8n7goWxN7dFA==/lib/arm, /system/lib, /vendor/lib]]

I have then tried to combine the code from the Google Assistant sample for Android Things with the Calendar API but looks like the Calendar API use a different Credential class from the Assistant sample (com.google.api.client.auth.oauth2.Credential vs com.google.auth.oauth2.UserCredentials).

Is there currently way to use the Calendar API from Android Things?

2

2 Answers

2
votes

I did find a way, involving a companion phone app to inject tokens into the things app. That being said, if you serialize the credentials and then deserialize them on boot, the phone app becomes optional, or you could use a service account.

Anyway, see here for what I explored.

1
votes

The standard system-level Calendar APIs will not work due to the account thing as you stated. You may be able to use the Google Calendar API for Android (instead of the Java guide). However, the lack of accounts on a device will still block you. If you use Firebase Auth and Nearby you can transfer a token from a phone companion app you can log in as a user on your device.

Then you may be able to use that token to get the access token for the user and make API calls.

Permissions added to your app will be granted after reboot.