onNewIntent() is not called in android Tabs

2020-03-04 07:29发布

问题:

I am working on one application. In my application I have three tabs. In the 3rd tab I have implemented some LinkedIn integration using their SDK, so that user can share on his LinkedIn account wall.

Everything seems to be working fine if I don't use this code inside tabs. But if I integrate the code that uses the LinkedIn SDK inside tabs, then onNewIntent() is not fired.

I am integrating LinkedIn like this:

        Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(liToken.getAuthorizationUrl()));
        i.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
        startActivity(i);

It basically opens a web page and when comes back it restarts my previous activity from where i called the LinkedIn SDK, but having no tabs at the bottom.

I want my app to come to my previous activity, and onNewIntent() should be called even when my code is moved inside tabs. How can I achieve it?

Thanks

回答1:

Set your activitys launchMode="singleTop" in the AndroidManifest.xml instead?



回答2:

I found that onNewIntent will be called as described in documentation if both launchMode="singleTop" and Intent.FLAG_ACTIVITY_SINGLE_TOP are setted.