0

Following is the flow I have

I have an BrowserActivity which runs an angular app inside WebView.

  1. The BrowserActivity opens an external webpage by using js method window.location.href = redirectUrl;, and this link is opened inside a chrome tab. I have also tried this by opening link in intent, same result.
  2. In the chrome tab some work is done and it provides you a link to return back to the original app.
  3. After I press that link a new activity is launched instead of returning to old activity, meaning onNewIntent is not called.
  4. The weird thing if I repeat the same process in new opened activity it calls neNewIntent instead of opening new activity.

Here is my manifest code for BrowserActivity

<activity android:name=".activities.BrowserActivity" android:theme="@style/AppTheme" android:screenOrientation="fullUser" android:launchMode="singleTop">
    <intent-filter>
        <action android:name="android.intent.action.VIEW"/>
        <category android:name="android.intent.category.DEFAULT"/>
        <category android:name="android.intent.category.BROWSABLE"/>
        <data android:host="host.mysite.com" android:scheme="https"/>
        <data android:host="host-dev.mysite.net" android:scheme="https"/>
        <data android:scheme="mysite-host"/>
        <data android:scheme="mysite-callback"/>
    </intent-filter>
</activity>

First time BrowserActivity is launched with following intent.

Note: I logged the scheme here. The scheme is null.

Intent intent = new Intent(context, BrowserActivity.class);
intent.putExtra(URL, url);
intent.putExtra(TITLE, title);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

First time the BrowserActivity loads 'mysite-host://host-dev.mysite.net/link1' and for returning from browser following link is provided 'mysite-callback://host-dev.mysite.net/link1/login/done'.

My question is why is onNewIntent is not fired the first time returning from browser.

sarosh
  • 97
  • 8

1 Answers1

0

It is because of the onNewIntent is not being called!!!

I put this on where this activity is get called.

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

then its works like a charm!!.

It is because of calling new activity. And FLAG_ACTIVITY_SINGLE_TOP makes onNewIntent get called. This FLAG_ACTIVITY_SINGLE_TOP will not start a new Activity.

Ref : https://stackoverflow.com/a/23446196

S_i_l_e_n_t C_o_d_e_r
  • 2,179
  • 2
  • 7
  • 21