Android Intent with Cordova - a new instance of the application is launched for each action. There must be only one

I want to share a link with other applications to mine.

I use this Phonegap plugin to implement intentions:

https://github.com/chrisekelley/olutindo-app/tree/master/plugins/com.borismus.webintent

The skills work, but every time I share the intention with another application, a new instance of my application starts, but I want to use one instance. If the application is already open, it must be reinitialized and brought to the forefront or restarted with initialization of the general intention.

I tried android: launchMode = "singleTop", but the same behavior happens, the application will open several times.

My manifest entry:

    <activity android:configChanges="orientation|keyboardHidden|screenSize"
        android:name=".StartActivity"
        android:label="@string/app_name"
        android:launchMode="singleTop" >
        <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.VIEW"></action>
            <category android:name="android.intent.category.DEFAULT"></category>
            <category android:name="android.intent.category.BROWSABLE"></category>
            <data android:mimeType="text/plain" />
        </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>

MainActivity, javascript (. PG ).

: android: launchMode = "singleInstance". , . , ?

!

+4
1

, . , launchMode="singleInstance" singleTask, .action.

, , - , .

final Intent myIntent = new Intent(this,
MainActivity.class);
myIntent.setAction("android.intent.action.MAIN"); //myIntent.setAction(Intent.ACTION_MAIN);
startActivity(myIntent);

. , , , .

+3

Source: https://habr.com/ru/post/1535584/


All Articles