From Delphi Demos Android Intents
ReceiveIntent project has one source file, Unit1.pas. It receives and shows the text from the SendIntent application.
•HandleIntentAction function verifies that the intent contains information and shows the text on the TMemo1.
•HandleAppEvent function verifies that the intent is not null and calls HandleIntentAction function with the received itent. This function handles the intent the first time ReceiveIntent opens.
•ReceiveIntent procedure handles the intent when ReceiveIntent is already open. The itent is registered using MainActivity.registerIntentAction(TJIntent.JavaClass.ACTION_VIEW);.To receive simple data from other applications, you need to update the Android Manifest file to create the intent filters that are necessary to receive intents for a specific action. After editing the Android Manifest for a specific action, when SendIntent application tries to share the information passing the intent to startActivity(), ReceiveIntent appears as the option to view this information. If more than one options is available, an app chooser with all the apps appears.
Registration
MainActivity.registerIntentAction(TJIntent.JavaClass.ACTION_VIEW);
Register the type of intent action that we want to be able to receive.
Note: A corresponding <action> tag must also exist in the <intent-filter> section of AndroidManifest.template.xml.
SubscribeToMessage
TMessageManager.DefaultManager.SubscribeToMessage
(TMessageReceivedNotification, HandleActivityMessage);
Modifying the AndroidManifest.xml
Modify the Android Manifest xml file to add the intent filter. An intent filter informs the Android system about what intents the application can accept. In this example, an intent filter is added to accept the intent created on the SendIntent application. The ReceiveIntent is the only application that can accept the intent from SendIntent application. The application that receives the intent needs to add some tags to the Android Manifest.
1.After building your project for the first time with Android selected on the Projects Window, the AndroidManifest.template.xml is added to your project folder.
2.Edit the AndroidManifest.template.xml file to add the following lines:
<!--<%application-meta-data%>
...
<activity android:name="com.embarcadero.firemonkey.FMXNativeActivity"
android:label="%activityLabel%"
android:configChanges="orientation|keyboard|keyboardHidden"
android:launchMode="singleTask">
...-->
<intent-filter>
...
<action android:name="android.intent.action.VIEW" /> <!--Constant Value for the ACTION_VIEW-->
<category android:name="android.intent.category.DEFAULT" /> <!-- Activities that want to receive implicit intents must include this constant-->
<category android:name="android.intent.category.BROWSABLE" />
<data android:mimeType="text/pas" /> <!--Sets the MIME type of your intent.-->
</intent-filter>
<!--</activity>-->