Unclear about Bare Workflow and Intent Filters

I’m running on SDK 42 and have an app that I’d like to add this sort of intent filter functionality:

<intent-filter>
  <action android:name="android.intent.action.PROCESS_TEXT" />
  <category android:name="android.intent.category.DEFAULT" />
  <data android:mimeType="text/plain" />
</intent-filter>

I put this into the app.json

      "intentFilters": [
        {
          "action": "android.intent.action.PROCESS_TEXT",
          "data": {
            "mimeType": "text/plain"
          },
          "category": ["android.intent.category.DEFAULT", "DEFAULT"]
        },
      ],

knowing that it wasn’t right but figuring it would at least generate an new manifest I could review. But no, when I run yarn android, nothing changes. So I’m thinking there’s something fundamentally wrong about my understanding of how this works or I am missing some other step to get this to trigger a modified manifest.

If you take the time to answer this, anything you can clarify about dev vs main or other relevant topics would be greatly appreciated. Happy just for pointers to some docs, however ever I’ve read through either assumes a higher level of knowledge than I have or doesn’t touch on this topic once you’ve switched to the bare workflow.

Thanks!

yarn android is probably running react-native run android under the hood (you can verify in package.json).

For changes in app.json to take affect, you’d need to run prebuild (which is run as part of commands like expo run:[ios | android] for managed projects or managed workflow builds on EAS Build). If you’re not making direct modifications to native files, I would recommend going that route. However, if you are making direct modifications to native files, then you’ll need to manually add the intent filters to your app in AndroidManifest by following Android’s docs

That was it. expo prebuild --clean --platform android --npm and it generated what I expected. Thank you.

For anyone else trying this, I learned that this

    "intentFilters": [
      {
        "action": "PROCESS_TEXT",
        "data": {
           "mimeType": "text/plain"
        },
        "category": ["DEFAULT"]
      },
    ],

will generate this:

      <intent-filter>
        <data android:mimeType="text/plain"/>
        <action android:name="android.intent.action.PROCESS_TEXT"/>
        <category android:name="android.intent.category.DEFAULT"/>
      </intent-filter>

which is to say that it knows how to generate the fully-qualified intent element values from the short names, like PROCESS_TEXT and DEFAULT.

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