0

I have found a several of reverse examples: sending from a React App to another one using intents.

I have found a blog post of a guy explaining how to do this with IOS.

But not on android. :(

What I understand from there is I need to add something in the `AndroidManifest.xml' file:

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

Am I right that this is the APP_ROOT/node_modules/react-native/ReactAndroid/src/main/AndroidManifest.xml file?

Should it look like that then?

<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.facebook.react">
    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
    <application />
    <activity android:name=".ShareLink">
        <intent-filter>
            <action android:name="android.intent.action.SEND" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:mimeType="text/plain" />
        </intent-filter>
    </activity>
</manifest>

How do I create the Intent?

Once my app is in the list (wohoo), how do I get back the data in the React App?

Any help would be highly appreciated. I'm a web developper, love React, but completely n00b to Android.

Community
  • 1
  • 1
Augustin Riedinger
  • 20,909
  • 29
  • 133
  • 206

1 Answers1

2

To get my app in the share list, it wasn't so hard at the end:

In <APP_ROOT>/android/app/src/main/AndroidManifest.xml:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.appname">

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

    <application
      android:allowBackup="true"
      android:label="@string/app_name"
      android:icon="@mipmap/ic_launcher"
      android:theme="@style/AppTheme">
      <activity
        android:name=".MainActivity"
        android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.SEND" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:mimeType="text/plain" />
          </intent-filter>
      </activity>
      <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
    </application>

</manifest>

But once it is in the list, to make it accessible to the React App, that was complicated. I detailed the steps in the next answer following another subquestion: https://stackoverflow.com/a/33969430/1620081

Community
  • 1
  • 1
Augustin Riedinger
  • 20,909
  • 29
  • 133
  • 206