I'm developing an app that is supposed to detect iBeacons. For this I'm using Android Beacon Library. I'm able to scan and detect the specified beacon. However, when I try to scan in the background I find the beacon, but I fail to bring app back to the front.
My testing process is the following: open the app -> start the scan -> press the back or home button on navigation bar -> enable iBeacon device

Code:

```
override fun didEnterRegion(region: Region?) {
        this.runOnUiThread {
            Log.d(TAG, "did enter region.")
            bringAppToFront()
            Toast.makeText(this, "Beacon found", Toast.LENGTH_SHORT).show()
        }
    }

```

```
fun bringAppToFront(){
        val intent = Intent(this, MainActivity::class.java)
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
        this.startActivity(intent)
    }

```

AndroidManifest.xml

```
<application
        android:allowBackup="true"
        android:launchMode="singleInstance"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/Theme.BeaconBackgroundScan">
        <activity
            android:name=".MainActivity"
            android:exported="true"
            android:label="@string/app_name"
            android:theme="@style/Theme.BeaconBackgroundScan.NoActionBar">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

```

Finally I receive the toast but the app doesn't reopen