0

Flow:

  1. Open app (MainActivity)
  2. Press home button ( calling onPause() in activity )
  3. Starting same activity, with different intent

    Intent intent = Utils.createIntent(....., this, MainActivity.class); // this will add some extra to our intent
            intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
            startActivity(intent);
    
  4. Nothing happens.

  5. onCreate() gets called. (onDestroy wasn't called)

  6. onResume() is called

My activity in xml

<activity
            android:name=".ui.activities.MainActivity"
            android:launchMode="singleTop"
            android:screenOrientation="portrait"
            android:windowSoftInputMode="adjustPan" />

NOte: if I don't press home button (app doesn't pause), onNewIntent will be called correctly.

4

1 回答 1

1

尝试设置此标志:

intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);

不客气!

于 2016-04-08T10:06:19.530 回答