Niki Trivedi
Niki Trivedi

Reputation: 1786

Android - Already opened app re-opens after clicking on the app from Search device apps

I have an app that is being restarted after being in the background then re-opened from searching application(Searching from all apps on device screenshot attached).

If i open simple from recent apps tab then it will not reopen the application.

I already read App Startup time documentation

But not able to conclude on anything.

My manifest code is

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

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
    <uses-permission android:name="android.permission.GET_TASKS" />
    <uses-permission android:name="android.permission.USE_CREDENTIALS" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.USE_FINGERPRINT" />

    <application
        android:name=".app.test"
        android:allowBackup="false"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:largeHeap="false"
        android:theme="@style/AppTheme"
        tools:replace="android:allowBackup">

        <activity
            android:name=".activity.StartupActivity_"
            android:screenOrientation="portrait"
            android:theme="@style/Theme.NoTitleNoActionBar">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".activity.test"
            android:screenOrientation="portrait"
            android:theme="@style/Theme.NoTitleNoActionBar" />
<! -- many more activity -->

 </application>
</manifest>

enter image description here

Upvotes: 0

Views: 705

Answers (1)

Radesh
Radesh

Reputation: 13575

If StartupActivity_ activity is that activity you leave it and then open from search!(complicated!) then you must add this line into manifest

 android:launchMode="singleTop"

Manifest code

    <activity
        android:name=".activity.StartupActivity_"
        android:screenOrientation="portrait"
        android:launchMode="singleTop"
        android:theme="@style/Theme.NoTitleNoActionBar">

This is good article to understand situations medium.com

Upvotes: 0

Related Questions