1

My app consists of 2 activities:

<activity
            android:name="com.domain.android.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>           
        <activity
            android:name="com.domain.android.AboutActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

I open my app, navigate to second screen, then go to the homescreen. From there I launch the app again - and it starts the main activity. But the app is running, it is just in the background, but why it didn't open the second activity? I guess it is something connected with activity's category. But how to fix that? Thanks.

Volodymyr
  • 1,557
  • 2
  • 14
  • 21

3 Answers3

1

Welcome to the ever-growing list of developers who have been bitten by this Android bug. Please see Re-launch of Activity on Home button, but...only the first time for all the gory details. And please go to Google Code and star the issues. We need all the noise we can make to get these fixed.

Community
  • 1
  • 1
David Wasser
  • 93,459
  • 16
  • 209
  • 274
  • But I tested other apps and they work! They keep the activity state even after launching them the second time! – Volodymyr May 17 '13 at 11:56
  • The problem occurs if the app is launched **for the first time** from the installer or from an IDE. Once the app is closed, after that everything works fine. A lot of apps have this behaviour, but some do not, because they have built in a workaround to deal with the problem. – David Wasser May 17 '13 at 12:16
  • In any case you should remove the `` from your `About` activity. That isn't necessary. – David Wasser May 17 '13 at 12:18
0

Hold your home button it will show the running apps click on your app it will open the activity from where you left. even if you click on the application launcher it will open the activity from where you left.

your application will not be in the same state sometimes if android needs resources it might end that activity. open an application move to next screen and press the home button and launch again it will open from where you left do the same with 5 or 6 apps then try launching the 1st app it will not be in the same state it will launch from the launch activity but any app you come to home screen and launch immediately it will open from where you left. If the background app is not doing anything android might end it if it needs resource. correct me if i am wrong. additional information i will be happy to know.

prvn
  • 916
  • 5
  • 5
  • 1
    This is exactly what **should happen**, but it doesn't. That's why OP asked the question. It's an Android bug. This answer isn't helpful. – David Wasser May 17 '13 at 11:32
  • i have enhanced my answer please let me know if my analysis is right or wrong - @David Wasser – prvn May 17 '13 at 11:52
  • I still think OP is troubled by the Android bug I linked to in my answer. But I may be wrong. – David Wasser May 17 '13 at 12:20
0

One issue may be that you have 2 activities designated as the main activity using:

<action android:name="android.intent.action.MAIN" />

You will probably have two icons in your launcher for your app. Each one will launch a different activity. You might be launching the first one again and again by using the icon for the first activity. Try removing

    <intent-filter>
        <action android:name="android.intent.action.MAIN" />

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

from your AboutActivity activity declaration. This might fix your problem.

Anup Cowkur
  • 20,443
  • 6
  • 51
  • 84