0

I have an activity that can be open with a widget and by pressing the icon. I am wondering how i close the old activity when I press the icon then the home button then the widget?


How I want it to work:

  1. open activity by pressing icon (show main view)
  2. do some stuff in activity(open dialog, change views, etc.)
  3. press home button (shows home screen)
  4. open activity with widget button (show main view)
  5. press back button (shows home screen)

How it actually works:

  1. open activity by pressing icon (show main view)
  2. do some stuff in activity(open dialog, change views, etc.)
  3. press home button (shows home screen)
  4. open activity with widget button (show main view)
  5. press back button (shows old activity opened with icon)

I have tried using android:clearTaskOnLaunch="true" android:finishOnTaskLaunch="true"

android:launchMode="singleTop" seems like it should work but it just opens the old activity with the changed view

is there any way to do this without using finish() in onUserLeaveHint()?

4

2 回答 2

1

启动时添加FLAG_ACTIVITY_CLEAR_TOP到您的意图MainActivity

于 2013-05-01T05:13:52.987 回答
0
android:launchMode="singleTop"

intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
于 2013-05-01T05:09:33.513 回答