首页 > 解决方案 > Receiving simple data from other apps launches another application

问题描述

I do sharing from other applications according to the instructions https://developer.android.com/training/sharing/receive

<activity
        android:name=".ui.activity.SplashActivity"
        android:configChanges="orientation"
        android:screenOrientation="portrait">
        <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" />
            <data android:mimeType="image/*" />
        </intent-filter>
    </activity>

The icon in the list of sharing in the gallery appeared, everything works as it should, only there is one problem. If the application is already running and sharing it into it, then the application starts in parallel on a new one. The application is run twice at the time of the mecn.

And in another activism inserted - the same thing

        <activity
        android:name=".ui.activity.SharingActivity"
        android:windowSoftInputMode="adjustPan"
        android:configChanges="orientation"
        android:screenOrientation="portrait">

        <intent-filter>
            <action android:name="android.intent.action.SEND" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:mimeType="image/*" />
        </intent-filter>

    </activity>

Does not matter, if the application is already running and sharing it into it, then the application starts in parallel on a new one. The application is run twice at the time of the mecn.

标签: androidduplicatesshare

解决方案


我修复了这个时刻/需要添加到清单中的活动

        android:launchMode="singleTask"

推荐阅读