Use React Native HeadlessJS to create background services that listen to Android Java Widget Providers (A Broadcast Receiver Service) 🤖
- Create buttons in Java / Android XML to triggers intents
- Process these intents from the Javascript side with all the tools and flexibility from react-native.
It is a bit complicated, and we developed it with 0 knowledge from Android or Java, so I apologize if it feels bad designed. Please help us improve the strategy / code layout with Pull Requests.
git clone https://github.com/jsdario/react-native-android-widget-poc
cd react-native-android-widget-poc
npm install # or yarn install
react-native link react-native-background-timer # to avoid the main thread
react-native run-android
To build your own android widget start from this project as a widget and hack upon or replicate the strategy to make it work.
🚧 This chapter is in construction
We haven't done this, but we belive that from this point has to be much easier,
having the strategy laid down, we'd need to create Native UI Components
calling methods from the RemoteView
class and context instead of the View
class.
It is not trivial to us, though.