Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do we get these "invalid" intents?

We have an app with an Activity that can be started in two ways:

  • From another Activity - always with some extra data filled in
  • From deep linking

As far as I can see this is always working just fine. We either get the Intent.ACTION_VIEW with a data URI, or we get some string extras.

However, we have a very few instances where action is Intent.ACTION_MAIN and there are no extra data.

The toString() of the Intent is as follows (class name changed):

Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10400000 cmp=com.example.OurActivity }

Intent.getExtras() returns null, Intent.getDataString() returns null.

In which cases can this happen? Why is the category for the Activity Intent.CATEGORY_LAUNCHER? How can we get the data needed to show the user the right contents?

launchMode is not specified for the Activity. The only IntentFilter in AndroidManifest.xml is for the deep linking (and not the launcher category).

The issue happens on Android 4-6 on a wide range of devices.

Edit: Forgot to mention the flags:

As the print out suggests the flags for the Intent are FLAG_ACTIVITY_NEW_TASK and FLAG_ACTIVITY_BROUGHT_TO_FRONT. I suppose that could be relevant here.

like image 457
Roy Solberg Avatar asked Sep 05 '16 10:09

Roy Solberg


1 Answers

I believe, I nailed it:

There're launchers, like Nova Launcher which allows users to start with any of app's Activities, instead of the normal flow:

enter image description here

For example, you can add a shortcut on your desktop to start Gmail client with Account setup Activity.

And in this case, Activity is being started with empty Extras and technically it becomes a launcher's Activity.

like image 164
Konstantin Loginov Avatar answered Nov 05 '22 05:11

Konstantin Loginov