Filter without action

The Android documentation says:

http://developer.android.com/reference/android/content/IntentFilter.html

"An action matches if any of the given values ​​matches the Intent action or if no actions were specified in the filter."

I just tried to check it out. In my test application, I set this filter for one of the actions:

<intent-filter>
    <action android:name="ma" />
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="mk1" />
</intent-filter>

I am trying to send such an intention:

Intent i = new Intent();
i.setAction("ma");
i.addCategory("mk1");
startActivity(i);

It works - my work begins.

Then I will comment on the action in the filter:

<intent-filter>
    <!-- <action android:name="ma" /> -->
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="mk1" />
</intent-filter>

Again I send the same intention. Now my activity does not begin.

Why? According to the documentation, when my filter didn’t indicate any actions, the intention with some actions should fill it.

+1
2

IntentFilters, :

, Intent , . ; , .

, , Intent, , . , :

  • - , , . .

  • , Intent, , - .

, IntentFilter, , Intent . , .


, , . , , , , " ", " Intent, , - ."

+1

i.setAction("ma"); .

0

Source: https://habr.com/ru/post/1618065/


All Articles