Jump to content
Sign in to follow this  
Massimiliano S

Using Intent - Chrome sharing does not work if App is already active

Recommended Posts

Hi,

I have an app that receives web url sharing via intent.

When I share from all apps or from any browser, my app receives the content and processes it correctly. If the app is not already open then it is successfully launched.
When I share with chrome the app is instead opened in chrome and if the app is already running it stops responding until I close the previous instance already active

 

Here my Manifest template

<application android:persistent="%persistent%"
android:restoreAnyVersion="%restoreAnyVersion%"
android:label="%label%"
android:debuggable="%debuggable%"
android:largeHeap="%largeHeap%"
android:icon="%icon%"
android:theme="%theme%"
android:usesCleartextTraffic="true"
android:hardwareAccelerated="%hardwareAccelerated%"
android:resizeableActivity="false">

<%provider%>
<%application-meta-data%>
<%uses-libraries%>
<%services%>
<!-- Our activity is a subclass of the built-in NativeActivity framework class.
This will take care of integrating with our NDK code. -->
<activity android:name="com.embarcadero.firemonkey.FMXNativeActivity"
android:label="%activityLabel%"
android:configChanges="orientation|keyboard|keyboardHidden|screenSize"
android:allowTaskReparenting="true"
android:launchMode="singleTask">
<!-- Tell NativeActivity the name of our .so -->
<meta-data android:name="android.app.lib_name"
android:value="%libNameValue%" />
<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="application/*" />
<data android:mimeType="message/*" />
<data android:mimeType="multipart/*" />
<data android:mimeType="text/*" />
</intent-filter>
</activity>
<%activity%>
<%receivers%>
</application>

 

OnCreate of Main Form

{$IFDEF ANDROID}
ContaIntent := 0;

if TPlatformServices.Current.SupportsPlatformService
(IFMXApplicationEventService, AppEventService) then
AppEventService.SetApplicationEventHandler(HandleAppEvent);

MainActivity.registerIntentAction(TJIntent.JavaClass.ACTION_VIEW);
MainActivity.registerIntentAction(TJIntent.JavaClass.ACTION_SEND);

TMessageManager.DefaultManager.SubscribeToMessage
(TMessageReceivedNotification, HandleActivityMessage);
{$ENDIF}

 

Thanks

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×