How to create separate Expo instance to show as an Android overlay?

Please provide the following:

  1. SDK Version: 49
  2. Platforms(Android/iOS/web/all): Android
  3. Add the appropriate “Tag” based on what Expo library you have a question on. N/A

I want to make an app that shows an overlay over the screen with some buttons the user can click no matter what app they are running. (This would be an Android-only app, but I want to write as much of the implementation using Expo as possible, not native Android Java/xml stuff).

To start, I created a basic expo app using npx create-expo-app. Since I couldn’t find any Expo module to do screen overlays, I followed the official expo tutorial for making a native module. Within that module, I made a new foreground service which adds a ViewGroup that displays hardcoded text over the screen. This worked successfully, but now I want to display arbitrary react-native components within the display-overlay.

Based on my understanding, an Expo/react-native app only runs a single “JSBridge” host by default to interface the app’s clicks and events with the host. Thus, if I were to kill the app through the system, then the bridge gets destroyed so there is no interface available to handle commands coming from touches on the display overlay.

Thus, I am wondering how could I launch a separate Expo “instance” or host that would be the backend to receive touches/events happening on the display overlay so that the overlay would be interactable?

I have already registered a dummy component on the React side that just displays a button:

AppRegistry.registerComponent("MyButton", () => MyButton);

So if there is some way to make a ReactRootView on the native side with its own dedicated JSBridge host or whatever, I should ideally be able to pull the “MyButton” component on the native side and have it display within the display-overlay independent of the main Expo app itself.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.