0

I have 3 activity tasks A-B-C

<activity android:name=".LoginActivity"
    android:label="@string/app_name"
    android:noHistory="true">
    <intent-filter>
        <action android:name="android.intent.action.MAIN"/>
        <category android:name="android.intent.category.LAUNCHER"/>
    </intent-filter>
</activity>
<activity android:name=".DashboardActivity"
              android:label="@string/app_name" >
</activity>
<activity android:name=".CreateNewPolygonActivity"
              android:label="@string/app_name"
              android:launchMode="singleTask"
              android:alwaysRetainTaskState="true"
              android:configChanges="orientation|keyboard|keyboardHidden">
</activity>
<service android:name=".services.RecordCircuitService"
             android:enabled="true" >
</service>

And I have a Service with GPS using LocationManager.

My application has this logic:

  1. On launcher icon clicked - > start login activity
  2. After login - > login activity is finish(); and start dashboardActivity
  3. In the dashboard I start CreateNewPolygonActivity and start the Service with GPS
  4. Press HOME (this is reorganize RecordActivity to foreground)

after I have some mistakes work

  1. open CreateNewPolygonActivity with onCreate
  2. open DashboardActivity

I think I have a problem with my task organization.

LOG_TAG
  • 19,894
  • 12
  • 72
  • 105
Vacxe
  • 91
  • 5

1 Answers1

0

You won't achieve the desired result by setting launchMode="singleTask" for your activity. Android won't create a separate task for this because you've not set the taskAffinity. In any case, you don't want to do this by using launchMode="singleTask" because this causes more problems than it solves. This launch mode is intended for HOME-screen replacements only!

Remove launchMode="singleTask"`` fromCreateNewPolygonActivity`

Also, you should remove android:noHistory="true" from your login activity. This isn't necessary either. Since you've already finished the login activity when the user starts the DashboardActivity, when he presses the BACK button, it won't return to the login activity (which I assume is what you wanted).

Once you've done these things, please tell us what is still broken.

David Wasser
  • 93,459
  • 16
  • 209
  • 274
  • Goes on to describe the situation 1) When I press the HOME button and not connected to other applications intrnet then the activity returns to normal 2) If the application uses the activity is recreated Perhaps it is a time of loss network (mcc mnc flags) and when the new network is reconnection? – Vacxe Mar 19 '13 at 12:57
  • Sorry, I'm having a lot of trouble understanding. Have you looked in the logcat to see if there are any errors? – David Wasser Mar 19 '13 at 13:10