Alon Minski
Alon Minski

Reputation: 1581

Launching app from HomeScreen (shortcut) and from App drawer, is not the same

I've encountered a weird behaviour. Maybe someone could clarify it. When I download my app from GooglePlay, there are 2 icons that are added. One goes to the Home Screen as a shortcut and another goes to the App Drawer (the screen with all the different installed apps I got on my device).

Now here is the flow of events:

  1. I install the app from GooglePlay
  2. I launch the app once installation is complete, also from GooglePlay (There's an open button) --> This launches the app, shows a splash screen and goes to my main screen
  3. I navigate around in my app to a different screen
  4. I click the home button to go to the Home Screen.

Now the interesting part:

  1. I press the Home Screen shortcut icon GooglePlay has created for me to get back to my app --> This takes me to the exact same screen I was in.
  2. I click the home button again to go to the Home Screen.
  3. This time, I press the App Drawer shortcut icon to get back to my app --> This shows the splash screen again and takes me to my main screen.

This happens constantly. Each shortcut launches to a different state (or screen). Notice that there is only one app in the Recent list.

On a the other hand. If I create the Home Screen shortcut myself, I get the same results when I launch the app from both icons. Something is different with the shortcut GooglePlay is creating for me.

Any ideas?

EDIT Here is the AndroidManifest.xml Some names where changed. Some information (that is not related to intent-filters) had to be removed..

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.xxxx.xxxxjh"
    android:installLocation="internalOnly">

<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="com.android.vending.BILLING" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

<application
    tools:node="replace"
    android:name=".xxxxgggApplication"
    android:allowBackup="true"
    android:icon="@drawable/icon"
    android:label="@string/app_name"
    android:largeHeap="true"
    android:hardwareAccelerated="true"
    android:theme="@style/AppTheme" >

    <activity
        android:name=".view.activities.StartupActivity"
        android:theme="@style/AppThemeNoBar"
        android:windojhoftInputMode="adjustResize|stateHidden">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <activity
        android:name=".view.activities.WelcomeActivity"
        android:theme="@style/WelcomeActivityStyle"/>

    <activity
        android:name=".view.activities.AccountActivity"
        android:theme="@style/AppThemeNoBar"
        android:windojhoftInputMode="adjustResize|stateHidden"/>

    <activity
        android:name=".view.activities.UrlSchemeHandlerActivity"
        android:launchMode="singleInstance">
        <intent-filter>
            <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" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />

            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />

            <data android:scheme="xxxx5.4" />
        </intent-filter>
    </activity>


    <activity
        android:name=".view.activities.FileManagerActivity"
        android:label="@string/app_name"
        android:launchMode="singleTask"
        android:logo="@drawable/fm_drawer"
        android:theme="@style/AppThemeBar"
        android:windojhoftInputMode="adjustPan|stateHidden"/>

    <activity
        android:name=".view.activities.ViewerActivity"
        android:label="@string/launcher_activity_label"
        android:theme="@style/AppThemeNoBar"
        android:windojhoftInputMode="adjustResize|stateHidden"
        android:parentActivityName=".view.activities.FileManagerActivity" >
        <!-- The meta-data element is needed for versions lower than 4.1 -->
        <meta-data
            android:name="android.support.PARENT_ACTIVITY"
            android:value=".view.activities.FileManagerActivity" />
    </activity>

    <activity
        android:name=".view.activities.DemoActivity"
        android:label="@string/launcher_activity_label"
        android:theme="@style/WelcomeActivityStyle"
        android:windojhoftInputMode="adjustResize|stateHidden" />

    <activity
        android:name=".view.activities.ApplicationSettingsActivity"
        android:logo="@drawable/fm_drawer"
        android:label="@string/AG_Settings"
        android:windojhoftInputMode="adjustResize|stateHidden">
        <meta-data
            android:name="android.support.PARENT_ACTIVITY"
            android:value="com.xxxx.xxxxjh.view.activities.FileManagerActivity" />

    </activity>

    <activity
        android:name=".view.activities.WebViewActivity"
        android:logo="@drawable/fm_drawer"
        android:theme="@style/AppThemeBar" />

    <service android:name="com.xxxx.sdk.controller.service.account.AccountService" >
       <!-- Actions and meta data goes here... -->
    </service>
    <service android:name="com.xxxx.sdk.controller.service.storage.StorageService">
       <!-- Actions and meta data goes here... -->
    </service>
    <service android:name="com.xxxx.sdk.controller.service.designFeed.DesignFeedService">
       <!-- Actions and meta data goes here... -->
    </service>
    <service android:name="com.xxxx.sdk.controller.service.ConfigService">
      <!-- Actions and meta data goes here... -->
    </service>

    <meta-data
        android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version" />

</application>

Upvotes: 0

Views: 1518

Answers (1)

Dr. Dreave
Dr. Dreave

Reputation: 539

I am sorry to tell you that this is not a bug in your project but an android default behaviour. I did some research ending up in the following threads. Maybe you can filter out some useful information and test these approaches in your project.

App completely restarting when launched by icon press in launcher

Android application restarts when opened by clicking the application icon

Greetz.

Upvotes: 1

Related Questions