2

As far as I know by default android app resumes when user clicks on its icon.

But for some reason my app (which I want to have the same behavior) restarts.

When I hold the home button and then select my app from "recent" I get it resumed. I want the same behavior on clicking the app icon.

actually it's the same as https://groups.google.com/forum/?fromgroups=#!topic/android-developers/UjWcsFMe6ik but they didn't find an answer

upd: manifest:

<?xml version="1.0" encoding="utf-8"?>

<uses-sdk a:minSdkVersion="10" a:targetSdkVersion="11"/>

<uses-permission a:name="android.permission.INTERNET"/>
<uses-permission a:name="android.permission.ACCESS_FINE_LOCATION"/>

<application a:label="@string/app_name"
             a:theme="@android:style/Theme.NoTitleBar"
             a:name="myapp.AppDelegate">

    <activity a:name="myapp.activities.AuthorizationActivity"
              a:label="@string/app_name"
              a:screenOrientation="portrait"
              a:alwaysRetainTaskState="true">
        <intent-filter>
            <action a:name="android.intent.action.MAIN"/>
            <category a:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
    </activity>


    <activity a:name="myapp.activities.activity1"
              a:screenOrientation="portrait"/>

    <activity a:name="myapp.activities.activity2"
              a:screenOrientation="portrait"/>
    ...

    <activity a:name="myapp.activities.activityN"
              a:screenOrientation="portrait"/>

    <service a:name="myapp.location.LocationService"/>

</application>

joao2fast4u
  • 6,868
  • 5
  • 28
  • 42
leshka
  • 1,764
  • 6
  • 32
  • 42
  • Are you clicking the default icon or your own widget? – Sam Nov 14 '12 at 20:11
  • I meant clicking icon in list of all applications – leshka Nov 14 '12 at 20:29
  • 3
    Does this answer your question? [App completely restarting when launched by icon press in launcher](https://stackoverflow.com/questions/16126511/app-completely-restarting-when-launched-by-icon-press-in-launcher) – yukashima huksay Apr 29 '20 at 04:17

3 Answers3

1

It's all about IDE. After closing an app which was started by IDE (eclipse or IDEA - doesn't matter) Android deletes all it's temporary data (don't ask me why)

So the solution is:

1) run app from ide (deploy it on device)
2) press back button to close an app
3) start an app again
...
and now it will resume working after quitting
leshka
  • 1,764
  • 6
  • 32
  • 42
0

Check launch mode of your activity. If its singleTask then make it standard and then check it.

Sheetal K
  • 1
  • 1
  • i didn't have launch mode specified at all. Added android:launchMode="standard" to my main activity - didn't solve the problem – leshka Nov 14 '12 at 20:27
0

Clicking the app icon will bring the task containing the main activity to the front.

To get the desired behavior make sure all your activities belong to the same task, i.e. don't use singleTask or singleInstance on any of the activities.

cketti
  • 1,277
  • 11
  • 15
  • I don't use any of them. The only "other process" part of my app is a service which continues running after closing my app. Which is ok. – leshka Nov 14 '12 at 20:34
  • What does the code look like you use to start new activities? – cketti Nov 16 '12 at 22:16