How can I respond to the Android broadcast ""?

We are migrating an Android app to Unity and one of the things the Android app does, is register itself as a broadcast receiver through the AndroidManifest like this:

    android:exported="true" >
        <action android:name="" />

The Android BroadcastReceiver is implemented like this:

public class OurReceiver extends BroadcastReceiver {
    public void onReceive(Context context, Intent intent) {
        String referrer = intent.getStringExtra("referrer");
        // do stuff with the referrer

Assuming I have C# code ready to do the stuff with the referrer, how can I do this in Unity?

What you need in order to achieve this:

  1. A custom JAR that contains your Java code (with the BroadcastReceiver).
  2. A custom AndroidManifest.xml like you posted that Unity will use.
  3. Some way of calling from the Java VM back into Unity.

Assuming you have a Java project wuth the BroadcastReceiver, you would need to compile it to JAR. Place the JAR in your Unity project under Assets/Plugins/Android

Also place the AndroidManifest.xml in that folder.

In order to call back into your scripting code from Java, use the UnityPlayer.UnitySendMessage.

See the documentation here on how to use it: Unity - Manual: Create and use plug-ins in Android