Action Bar "Run Intent" Mode

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:

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

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

Here is the listener:

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:

This is the error logged when the action is triggered:

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

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?

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.

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  |  Desarrolladores de Android  |  Android Developers

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, 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

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:
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:
<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:
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
1 Like

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?

1 Like

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