2 instances of the app opening

Hi!

The issue:
When the app is playing in the background, if I press app icon in launcher, it opens one more instance of the app instead of going to the already running app. How to get rid of it?

Thanks!

You need to specify activity/screen’s launch mode as singleTask.

Thank you! Do I do it by editing manifest?

I know nothing about changing the manifest file. Right now I have “ManifestCode” by Atom, which was required for correct AI2 media notification working. How do I change it by adding android:launchMode=“singleTop” to it?

Oh, that’s not gonna help you. That’s for adding things to the manifest, not really modifying them.

1 Like

Anyway, how do I add android:launchMode="singleTop"
to the manifest that is already there?

Search the community for how to modify the manifest.

1 Like

SingleTop != SingleTask

Oh, you mean there is error in typo, thank you!

Modified manifest in manifestgenerator by Atom. It didn’t work. Still opening one more instance, by clicking at app icon in launcher or in notification…

I wonder when I suggested you to use that. :thinking:

1 Like

Sorry for being noobish, I keep on learning.
Just modified manifest.xml in APK editor studio.
Still no success…

Can you show how it looks now?

<?xml version="1.0" encoding="utf-8" standalone="no"?>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:launchMode="singleTop"/>
<application android:debuggable="false" android:icon="@mipmap/ic_launcher" android:label="Radio Bagus" android:name="com.google.appinventor.components.runtime.multidex.MultiDexApplication" android:networkSecurityConfig="@xml/network_security_config" android:requestLegacyExternalStorage="true" android:roundIcon="@mipmap/ic_launcher" android:supportsRtl="true" android:theme="@style/AppTheme" android:usesCleartextTraffic="true">
    <activity android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize" android:name="io.kodular.shooroopski.Radio_Bagus.Screen1" android:theme="@style/AppTheme.NoActionBar" android:windowSoftInputMode="stateHidden">
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>
            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
    </activity>
    <activity android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize" android:name="io.kodular.shooroopski.Radio_Bagus.Main" android:theme="@style/AppTheme.NoActionBar" android:windowSoftInputMode="stateHidden">
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>
        </intent-filter>
    </activity>
    <meta-data android:name="io.kodular.app.VERSION" android:value="1.4D.1-Eagle"/>
    <service android:enabled="true" android:exported="true" android:name="de.ullisroboterseite.ursai2medianotificationk.ForegroundService"/>
    <provider android:authorities="io.kodular.shooroopski.Radio_Bagus.provider" android:exported="false" android:grantUriPermissions="true" android:name="android.support.v4.content.FileProvider">
        <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/provider_paths"/>
    </provider>
    <uses-library android:name="org.apache.http.legacy" android:required="false"/>
    <meta-data android:name="RCWTFYP-BYDNKHMWRIT-DNLATT_TK" android:value="eyJraWQiOiJrMSIsImFsZyI6IlJTMjU2In0.eyJpc3MiOiJKdW5ub3ZhdGUsIExMQyIsImF1ZCI6IktvZHVsYXIgQ3JlYXRvciBbY3JlYXRvci5rb2R1bGFyLmlvXSIsInN1YiI6ImlvLmtvZHVsYXIuc2hvb3Jvb3Bza2kuUmFkaW9fQmFndXMiLCJqdGkiOiJ5T0RhWndwZ0FlR1BlYUpEV0Rwa1V3IiwiaWF0IjoxNjIzNTQ4NzM1LCJuYmYiOjE2MjM1NDg3MzUsImNvbSI6Ik1TNHcifQ.R6C5gna6bIwox38NBofPBlfa6XUwPw7iaFCn6XfK4rutpufe6pRGywVZ3KpTYNHDePK9EI2AozAIA3XHBzjwslohU4CyT0fvcMPko-mALSZOeiIAN9hmNYDA3NOTV3tUgHP96E1RMmDARygBxDGrmozgvDRJhZJJ1uj_JeozWIcibG6oWHeKGSDltrd_bEB3U9cOqynAh_bgthCKXlQQfIjqibF5hqAUvjw2SeWCJsn6eRdkQxAeOkP4mDbAm2-M6nP7gOKfAV3AEIV4hXUKP9IQuQ2DRt4MgphZ9K9MESWAOGjzfCaTtt1D8zbjX6Y_-alHaTYeus777xP-hSz6Ug"/>
    <meta-data android:name="RCWTFYP-BYDNKHMWRIT-DNLATT_PK" android:value="MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAoseRxi3lppFuMrvc1fOAOl130AmrTC3iQQbdAjtj9Cbkk52+b6PAsHsAw1sUhAj6t51W47XKBldpdPYt3VaxRugRVISVbCckEzbWP3kcpjsZ7cjfZz4tk7RGnZce3/q9/4qQx/bx4eu6fMxhSAWF50xzs9FoR827yDxBYgZUJOlUSYKQQKopIfd8UFk279ZgWaCKU6r8AVl4GEFPzR3FeNC34NPML2gNAvKLCp+gW+EiZ+sB0QDLy0JSnBXvyvUz6RcbDm0FskkpC5mqQPeQC1YPeydlY1WkiKXeSUUqxXlNcVPyporxGPzeTKd3Z+B8c+N5Jv2xYOWJ0vl4yGNoVQIDAQAB"/>
</application>

I wrote singleTop instead of singleTask, because there is so: How to prevent the app from restarting when I touch the experimental notification component? - #2 by lc_rossil

It is not a permission.

You were supposed to add that here.

Oh, thank you, Sunny Gupta! Will check it right away.

Hm… Now the app refuses to install.

<?xml version="1.0" encoding="utf-8" standalone="no"?>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<application android:debuggable="false" android:icon="@mipmap/ic_launcher" android:label="Radio Bagus" android:name="com.google.appinventor.components.runtime.multidex.MultiDexApplication" android:networkSecurityConfig="@xml/network_security_config" android:requestLegacyExternalStorage="true" android:roundIcon="@mipmap/ic_launcher" android:supportsRtl="true" android:theme="@style/AppTheme" android:usesCleartextTraffic="true">
    <activity android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize" android:launchMode="singleTop" android:name="io.kodular.shooroopski.Radio_Bagus.Screen1" android:theme="@style/AppTheme.NoActionBar" android:windowSoftInputMode="stateHidden">
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>
            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
    </activity>
    <activity android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize" android:name="io.kodular.shooroopski.Radio_Bagus.Main" android:theme="@style/AppTheme.NoActionBar" android:windowSoftInputMode="stateHidden">
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>
        </intent-filter>
    </activity>
    <meta-data android:name="io.kodular.app.VERSION" android:value="1.4D.1-Eagle"/>
    <service android:enabled="true" android:exported="true" android:name="de.ullisroboterseite.ursai2medianotificationk.ForegroundService"/>
    <provider android:authorities="io.kodular.shooroopski.Radio_Bagus.provider" android:exported="false" android:grantUriPermissions="true" android:name="android.support.v4.content.FileProvider">
        <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/provider_paths"/>
    </provider>
    <uses-library android:name="org.apache.http.legacy" android:required="false"/>
    <meta-data android:name="RCWTFYP-BYDNKHMWRIT-DNLATT_TK" android:value="eyJraWQiOiJrMSIsImFsZyI6IlJTMjU2In0.eyJpc3MiOiJKdW5ub3ZhdGUsIExMQyIsImF1ZCI6IktvZHVsYXIgQ3JlYXRvciBbY3JlYXRvci5rb2R1bGFyLmlvXSIsInN1YiI6ImlvLmtvZHVsYXIuc2hvb3Jvb3Bza2kuUmFkaW9fQmFndXMiLCJqdGkiOiJ5T0RhWndwZ0FlR1BlYUpEV0Rwa1V3IiwiaWF0IjoxNjIzNTQ4NzM1LCJuYmYiOjE2MjM1NDg3MzUsImNvbSI6Ik1TNHcifQ.R6C5gna6bIwox38NBofPBlfa6XUwPw7iaFCn6XfK4rutpufe6pRGywVZ3KpTYNHDePK9EI2AozAIA3XHBzjwslohU4CyT0fvcM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