I'm trying to implement Facebook's Deep Linking feature on my app and encountered the following scenario:

I have an activity called MainActivity which is declared like so:

    <activity
        android:name="com.mypackage.android.MainActivity">

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

This activity + my package name are also declared in my app's settings on facebook developer website.

Once a link gets clicked on Facebook's app, I'm supposed to handle this event via the onCreate method of my activity. The following code handle the event:

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        Uri target = getIntent().getData();

        if (target != null){
          // got here via Facebook deep link
          // once I'm done parsing the URI and deciding
          // which part of my app I should point the client to
          // I fire an intent for a new activity and
          // call finish() the current activity (MainActivity)
        }else{
          // activity was created in a normal fashion
        }
    }

All goes according to plan except for the following scenario:

  1. User launched my app
  2. MainActivity created
  3. SecondaryActivity created
  4. MainActivity finished
  5. App goes to background via the device home button
  6. Deep link gets clicked on Facebook's app

In this case my app goes to foreground again, but MainActivity's onCreate / onNewIntent don't get called, instead SecondaryActivity's onResume() gets called and restored to it's last state.

Note: I've tested this issue on a Samsung Nexus with Android 4.2.1 and got to this result, though when tested on Ga

Edit
Report