public Intent getLaunchIntent(Context appContext) {
        try {
            // The desired behavior upon notification opening is as follows:
            // - If app is in foreground (and possibly has several activities in stack), simply keep it as-is in foreground.
            // - If app is in background, bring it to foreground as-is (context stack untampered).
            //   A distinction is made in this case such that if app went to back due to *back-button*, is should be recreated (this
            //   is Android's native behavior).
            // - If app is dead, launch it through the main context (as Android launchers do).
            // Overall, THIS IS EXACTLY THE SAME AS ANDROID LAUNCHERS WORK. So, we use the same configuration (action, categories and
            // flags) as they do.
            final Intent helperIntent = appContext.getPackageManager().getLaunchIntentForPackage(appContext.getPackageName());
            final Intent intent = new Intent(appContext, Class.forName(helperIntent.getComponent().getClassName()));
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
            intent.putExtra(LAUNCH_FLAG_KEY_NAME, true);
            return intent;
        } catch (ClassNotFoundException e) {
            // Note: this is an imaginary scenario cause we're asking for a class of our very own package.
            if(BuildConfig.DEBUG) Log.e(TAG, "Failed to launch/resume app", e);
            return null;
        }
    }
@Test
    public void getLaunchIntent__returnsCustomIntentWithNotifFlagExtra() throws Exception {
        final AppLaunchHelper uut = getUUT();
        Intent intent = uut.getLaunchIntent(mContext);

        assertNotNull(intent);
        assertEquals(APP_PACKAGE_NAME, intent.getComponent().getPackageName());
        assertEquals(APP_MAIN_ACTIVITY_NAME, intent.getComponent().getClassName());
        assertEquals(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED, intent.getFlags());
        assertTrue(intent.getBooleanExtra(LAUNCHED_FROM_NOTIF_BOOLEAN_EXTRA_NAME, false));
    }