React-native-track-player: App is relaunching on notification click

Created on 10 Nov 2018  路  11Comments  路  Source: react-native-kit/react-native-track-player

I have tried putting android:launchMode="singleTop" in the android manifest but it doesn't work.

Android Bug

Most helpful comment

Can you try dbe11d12b64f7a209bb9f4b4597ad2f33813e3a8, please?

All 11 comments

Can you try dbe11d12b64f7a209bb9f4b4597ad2f33813e3a8, please?

Thank you. This solved the problem.

This also fixed it for me, thanks! Any idea when this will be merged?

Thanks again for the library

@Guichaguri I can see that it's already in the current version though I still have the problem of app restarting :s

@ishigamii when are you experiencing this issue? Is it when the app is closed (in background) and you press the notification? Or is it when the app is already open and it still reopens?

@Guichaguri On Android In both cases to be honest I tested it and got this on both simulator and real device. The app open again but the track keeps going like normal.
Maybe it's my manifest configuration which is wrong ?

Can you share your manifest file so I can take a look?

@Guichaguri Yes no problem

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.xxxx">

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.RECORD_VIDEO"/>
    <uses-permission android:name="android.permission.RECORD_AUDIO"/>
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
    <uses-permission android:name="android.permission.VIBRATE" />

    <application
      android:name=".MainApplication"
      android:label="@string/app_name"
      android:icon="@mipmap/ic_launcher"
      android:allowBackup="false"
      android:launchMode="singleTop"
      android:theme="@style/AppTheme">
        <activity
            android:name=".SplashActivity"
            android:label="@string/app_name"
            android:exported="true"
            android:theme="@style/SplashTheme">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
      <activity
        android:name=".MainActivity"
        android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
        android:screenOrientation="portrait"
        android:windowSoftInputMode="adjustResize"
          android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.DOWNLOAD_COMPLETE"/>
            </intent-filter>
            <intent-filter android:label="filter_react_native">
              <action android:name="android.intent.action.VIEW" />
              <category android:name="android.intent.category.DEFAULT" />
              <category android:name="android.intent.category.BROWSABLE" />
                <data android:scheme="xxxx" android:host="post" />
            </intent-filter>
      </activity>
      <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
        <service android:name="io.invertase.firebase.messaging.RNFirebaseMessagingService">
            <intent-filter>
                <action android:name="com.google.firebase.MESSAGING_EVENT" />
            </intent-filter>
        </service>
        <service android:name="io.invertase.firebase.messaging.RNFirebaseInstanceIdService">
            <intent-filter>
                <action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
            </intent-filter>
        </service>
        <service android:name="io.invertase.firebase.messaging.RNFirebaseBackgroundMessagingService" />

        <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id"/>

        <meta-data
            android:name="com.google.firebase.messaging.default_notification_icon"
            android:resource="@drawable/notification" />
        <meta-data
            android:name="com.google.firebase.messaging.default_notification_color"
            android:resource="@color/notification_color" />

        <meta-data
            android:name="com.google.firebase.messaging.default_notification_channel_id"
            android:value="@string/default_notification_channel_id"/>
    </application>
</manifest>

The android:launchMode="singleTop" property should be added to the <activity> tag

@Guichaguri sorry for the delay
I actually tried to move it to the activity as you said and place it instead in the first activity android:name=".SplashActivity" but it didn't change the problem. So I tried to put it in the second android:name=".MainActivity" and same result. And I tried to put it in both and same result :/ (maybe I am doing some strange things as I am not very used to android development sorry if I do)

Anything else in the configuration that could produce this ? For the record I am using
"react-native-track-player": "^1.1.2",
and
"react-native": "0.55.4",

@Guichaguri Solved this with removing my SingleTop and adding android:launchMode="singleTask" to AndroidManifest.xml under the activity android:name=".MainActivity". Hope the SingleTop wasn't needed for something else though ^^

Thanks for your help 馃憤

Was this page helpful?
0 / 5 - 0 ratings

Related issues

krunalbad picture krunalbad  路  3Comments

fabiocosta88 picture fabiocosta88  路  3Comments

KalebPortillo picture KalebPortillo  路  4Comments

sagargheewala picture sagargheewala  路  3Comments

moduval picture moduval  路  4Comments