Integrate RaspberryPi with Sleep As Android

Hello!
I’ve got an idea to make a kind of ‘non-wearable’ wearable out of my Raspberry Pi that already sucessfully runs some sensors (PIR, etc.) and can connect to Android Phone via Bluetooth, but I’m having trouble integrating it with the Sleep app.

Firstly, it’s not obvious, what exactly API should I use: intent API or wearables API.
As I understood, to use wearable API, Sleep app somehow should detect my device as ‘connected’, which it probably will not, as it is not whitelisted, right?

(It would be really great to be able to use the Wearable API instead of Intent API, so that I don’t need to create my own Android app. :slight_smile: )

Anyway, I tried to use intent API and even created some kind of a transitional, intermediate Android app that would collect data from Raspberry Pi’s sensors over Bluetooth and send it to Sleep as Android. But… seems like I cannot make Sleep app intentions working.

I used MIT App Inventor 2 to create the intermediate app and tried to send the very first intent to Sleep app with this:

And I’ve got 601 error ‘No corresponding activity was found’.

Maybe should I also set the ActivityClass (but to what value? no docs on that matter) or something else to make it work? Or am I doing something conceptually wrong? Just FYI, I actually managed to trigger some other intent com.urbandroid.sleep.ACTION_START_SLEEP_TRACK_FROM_ACTIVITY, it, ofc, finished with an error, but at least I understood Sleep is responsive to intents from my app in general.

P.S. I’m not an android dev, so all this intent-stuff is kind of new to me.

Hello @Larleyt,

the problem is that Google is adding more and more restrictions to Android and since Android 8.0 apps can no longer send out intents for all apps but just for a selection of packages… So we would in fact need to your apps package name as one of the supported wearable add-ons…

If you want to test this out, please send me your package name and I will prepare a special build of sleep as android for you which will talk to your app…

Hello @petr-urbandroid,

Thanks for a quick response.

These restrictions look like a serious complication for Android developers.
My app isn’t published yet and (at least for now) won’t be, but I’ve built an .apk from MIT App Inventor and got the pkg name:

appinventor.ai_poker_kmv.SleepTracker

Yet I would like to ask you to also add the Inventor Companion itself:

edu.mit.appinventor.aicompanion3

Basically, the last one allows to connect phone and debug changes in the MIT App Inventor, test intents and so on in real time, without building an .apk, so that would be a huge performance improvement. :slight_smile:

Also, regarding one of the original questions, is there a way to use wearable API with a custom device to skip all these android app movements or is it inevitable? :slight_smile:

As I understood, to use wearable API, Sleep app somehow should detect my device as ‘connected’, which it probably will not, as it is not whitelisted, right?

Hello @Larleyt… for the next BETA version… I’m adding a DYI option to the wearable selection dialog… This will prompt you for a package name and all the intents from the Wearable API doc will be send to that package name…

Hope that helps…

To get the BETA:
Please first join our BETA Testers group at:
https://groups.google.com/forum/#!forum/sleep-as-an-droid
That you can opt-into the BETA at the following address:
https://play.google.com/apps/testing/com.urbandroid.sleep
Or simply by visiting our Play Store listing and tapping “Join BETA”

1 Like