testivanivan
testivanivan

Reputation: 1514

Android. What is by default value for exported of components which has IntentFilter in Android lower 12?

When apps targeting Android 12 and higher are required to specify an explicit value for android:exported when the corresponding component has an intent filter defined. But when apps targeting 11 or lower and in Manifest for component no set exported what is the default value for exported ? My all components with intent filter are exported ?

Upvotes: 0

Views: 975

Answers (2)

devconsole
devconsole

Reputation: 7915

I think you should set the value explicitly.

Quoting from developer.android.com:

The logic behind the default value of this attribute changed over time and was different depending on the component types and Android versions. For example, on API level 16 (Android 4.1.1) or lower the value for elements is set to true by default. Not setting this attribute explicitly carries the risk of having different default values between some devices.

Upvotes: 0

CommonsWare
CommonsWare

Reputation: 1007399

For <activity>, <service>, and <receiver>, the default android:exported value is true if the component has an <intent-filter>, false, otherwise.

For example, here is the documentation for android:exported on <service>:

The default value depends on whether the service contains intent filters. The absence of any filters means that it can be invoked only by specifying its exact class name. This implies that the service is intended only for application-internal use (since others would not know the class name). So in this case, the default value is "false". On the other hand, the presence of at least one filter implies that the service is intended for external use, so the default value is "true".

Upvotes: 2

Related Questions