# Action Bar "Run Intent" Mode

**URL:** <https://community.xibo.org.uk/t/action-bar-run-intent-mode/28840>\
**Category:** Xibo Player for Android\
**Created:** [February 14, 2023, 5:01pm UTC](https://community.xibo.org.uk/t/action-bar-run-intent-mode/28840 "2023-02-14T17:01:03Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nuno\_Veloso](https://community.xibo.org.uk/user_avatar/community.xibo.org.uk/nuno_veloso/32/13278_2.png) [@Nuno\_Veloso](https://community.xibo.org.uk/u/Nuno_Veloso)\
**Post date:** [February 14, 2023, 5:01pm UTC](https://community.xibo.org.uk/t/action-bar-run-intent-mode/28840/1 "2023-02-14T17:01:03Z")

</div>

Hello,

I’m trying to setup the “Run Intent” feature of the Xibo Player (for Android) action bar, the idea is to trigger an action of an App that is listening for this intent. Unfortunately, I can’t get it to work.

I’ve used these threats as reference:

- [Switching Apps on Xibo for Android](https://community.xibo.org.uk/t/switching-apps-on-xibo-for-android/19577)
- [How set commands to switching Apps on Xibo for Android?](https://community.xibo.org.uk/t/how-set-commands-to-switching-apps-on-xibo-for-android/22933/1)

This is the `intent-filter` I’ve added to the `AndroidManifest.xml`:

```auto
<intent-filter>
   <action android:name="com.example.MY_ACTION" />
   <category android:name="android.intent.category.DEFAULT" />
</intent-filter>

```

Here is the listener:

```auto
public class ActionReceiver extends BroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {
        Toast.makeText(context, intent.getStringExtra("test"), Toast.LENGTH_LONG).show();
    }
}

```

And this is how I’ve configured Xibo:

 ![Screenshot 2023-02-14 at 16.53.28](https://community.xibo.org.uk/uploads/default/original/2X/b/b3642e5222cc8e3fa9382e513e49fb37578e0847.png)

---

<div class="post-metadata">

**Author:** ![Nuno\_Veloso](https://community.xibo.org.uk/user_avatar/community.xibo.org.uk/nuno_veloso/32/13278_2.png) [@Nuno\_Veloso](https://community.xibo.org.uk/u/Nuno_Veloso)\
**Post date:** [February 16, 2023, 6:07pm UTC](https://community.xibo.org.uk/t/action-bar-run-intent-mode/28840/2 "2023-02-16T18:07:05Z")

</div>

This is the error logged when the action is triggered:

 ![Screenshot 2023-02-16 at 18.05.24](https://community.xibo.org.uk/uploads/default/original/2X/e/e8486a5bc18767ee0a361b41977a6c7e667bc0ea.png)

---

<div class="post-metadata">

**Author:** ![Vishal\_Debipersad](https://community.xibo.org.uk/user_avatar/community.xibo.org.uk/vishal_debipersad/32/10360_2.png) [@Vishal\_Debipersad](https://community.xibo.org.uk/u/Vishal_Debipersad)\
**Post date:** [February 17, 2023, 10:23am UTC](https://community.xibo.org.uk/t/action-bar-run-intent-mode/28840/3 "2023-02-17T10:23:01Z")

</div>

you could also run a command if you can get this intent working in a terminal

---

<div class="post-metadata">

**Author:** ![Nuno\_Veloso](https://community.xibo.org.uk/user_avatar/community.xibo.org.uk/nuno_veloso/32/13278_2.png) [@Nuno\_Veloso](https://community.xibo.org.uk/u/Nuno_Veloso)\
**Post date:** [February 20, 2023, 10:36am UTC](https://community.xibo.org.uk/t/action-bar-run-intent-mode/28840/4 "2023-02-20T10:36:37Z")

</div>

Hi @Vishal_Debipersad, I appreciate your response. I can get the intent working in the terminal, can you please elaborate on what you are suggesting?

---

<div class="post-metadata">

**Author:** ![Vishal\_Debipersad](https://community.xibo.org.uk/user_avatar/community.xibo.org.uk/vishal_debipersad/32/10360_2.png) [@Vishal\_Debipersad](https://community.xibo.org.uk/u/Vishal_Debipersad)\
**Post date:** [February 22, 2023, 10:02am UTC](https://community.xibo.org.uk/t/action-bar-run-intent-mode/28840/5 "2023-02-22T10:02:12Z")

</div>

Hi,

Lets say you are using this on an Android device, you could simply run a command from Xibo. If you are using Xibo player on a rooted device, it will easily accept the command to run.

Example of how I use commands to run something from terminal, note that echo is not needed, depends on your command.

 ![image](https://community.xibo.org.uk/uploads/default/original/2X/2/22a650d85aa362092d28d9fcdf2f97a251daffce.png)

---

<div class="post-metadata">

**Author:** ![dan](https://community.xibo.org.uk/user_avatar/community.xibo.org.uk/dan/32/9115_2.png) [@dan](https://community.xibo.org.uk/u/dan)\
**Post date:** [February 28, 2023, 9:02am UTC](https://community.xibo.org.uk/t/action-bar-run-intent-mode/28840/6 "2023-02-28T09:02:00Z")

</div>

Hi,

I think the error logged comes from the example app rather than Xibo - i.e. Xibo is sending the intent as expected but the example app is not able to listen to it.

There is some information on why this might be happening here: [Límites de ejecución en segundo plano &nbsp;|&nbsp; Desarrolladores de Android &nbsp;|&nbsp; Android Developers](https://developer.android.com/about/versions/oreo/background#broadcasts)

When Xibo sends the intent configure it is not implicit because the app doesn’t know anything about the application who will receive it - therefore it falls under the new restrictions in later versions of android.

It is my understanding that if you register your listener at runtime instead using [`registerReceiver`](https://developer.android.com/reference/android/content/Context#registerReceiver(android.content.BroadcastReceiver,%20android.content.IntentFilter)), it should work.

As a side note, I think the same restrictions would apply to running a command, as this is an issue with receiving the intent not sending it.

Thanks,  
Dan

---

<div class="post-metadata">

**Author:** ![Nuno\_Veloso](https://community.xibo.org.uk/user_avatar/community.xibo.org.uk/nuno_veloso/32/13278_2.png) [@Nuno\_Veloso](https://community.xibo.org.uk/u/Nuno_Veloso)\
**Post date:** [March 8, 2023, 1:36pm UTC](https://community.xibo.org.uk/t/action-bar-run-intent-mode/28840/7 "2023-03-08T13:36:18Z")

</div>

Thanks for your support @dan, I was able to achieve the goal with the following step:

1. Define a `BroadcastReceiver` class that will receive the intent. In this class, override the `onReceive()` method to perform the desired action when the intent is received. For example:

```auto
public class MyReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        // Perform action here
    }
}

```

1. In the app’s manifest file, declare the `BroadcastReceiver` with an `<intent-filter>` that specifies the action and package name of the external app. For example:

```auto
<receiver android:name=".MyReceiver">
    <intent-filter>
        <action android:name="com.example.MY_ACTION" />
        <category android:name="android.intent.category.DEFAULT" />
        <data android:scheme="package" android:path="uk.org.xibo.client" />
    </intent-filter>
</receiver>

```

1. In the app’s code, register the `BroadcastReceiver` with the `IntentFilter` that matches the action string used by the external app. For example:

```auto
MyReceiver receiver = new MyReceiver();
IntentFilter filter = new IntentFilter("com.example.MY_ACTION");
registerReceiver(receiver, filter);

```

1. Setup Xibo Action Bar Mode & Intent like this:  
 ![intent](https://community.xibo.org.uk/uploads/default/original/2X/1/15f3810d2d5f61abfc214b54e22345b221d05c4a.png)

---

<div class="post-metadata">

**Author:** ![dan](https://community.xibo.org.uk/user_avatar/community.xibo.org.uk/dan/32/9115_2.png) [@dan](https://community.xibo.org.uk/u/dan)\
**Post date:** [March 8, 2023, 5:16pm UTC](https://community.xibo.org.uk/t/action-bar-run-intent-mode/28840/8 "2023-03-08T17:16:14Z")

</div>

Fantastic - I am pleased to hear you have it working and thank you for posting details of how you achieved that.

@natasha - shall we move this into a KB?

---

<div class="post-metadata">

**Author:** ![system](https://community.xibo.org.uk/uploads/default/original/2X/a/a8759c2d8cc561474733895ac75beeb830f5d8ca.png) [@system](https://community.xibo.org.uk/u/system)\
**Post date:** [June 7, 2023, 11:16pm UTC](https://community.xibo.org.uk/t/action-bar-run-intent-mode/28840/9 "2023-06-07T23:16:53Z")

</div>

Closed on June 7, 2023, 11:16pm UTC

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