Is the optional inclusion of an activity alias in a manifest with support for android: enabled = "@ bool / tablet" or "@ bool / phone"?

To avoid any wiring of the tablet / phone, I want my application to self-determine using the activity alias and make the manifest system delivered to the main action (for the tablet) or a new action (for the phone).

If I have this in my manifest:

<activity-alias android:name="my.app.WebContent" android:targetActivity="my.app.activities.Home"/> 

then everything is fine and

 Intent { act=android.intent.action.VIEW dat=http://www.app.my/url cmp=my.app/.WebContent (has extras) } 

Shipped as expected.

If, however, I have this in my manifest:

 <activity-alias android:name="my.app.WebContent" android:enabled="@bool/has_one_pane" android:targetActivity="my.app.activities.WebContent"/> <activity-alias android:name="my.app.WebContent" android:enabled="@bool/has_two_panes" android:targetActivity="my.app.activities.Home"/> 

with this value /res.xml

 <resources> <bool name="has_two_panes">false</bool> <bool name="has_one_pane">true</bool> </resources> 

and this is in the values-large / res.xml and values-sw600dp / res.xml:

 <resources> <item type="layout" name="content_frame">@layout/activity_item_twopane</item> <bool name="has_two_panes">true</bool> <bool name="has_one_pane">false</bool> </resources> 

then my code filters the intent as "invalid" according to PackageManager.resolveActivity ().

It seems that values ​​/res.xml overrides the values-nothing / res.xml, although large values ​​should override the values ​​/res.xml for large displays.

Is this a bug in Android, or did I misunderstand how to do this?

+1
source share
1 answer

No, this is not supported, because things like screen width (res / layout-w600dp) may change in orientation, but Google did not seem to notice that this "minimum width" (res / layout-sw600dp ) it does not affect. See Changing the orientation of a fragment - a better test than for landscape

Please note that the workaround suggested in How to specify actions that are intended only for Android phones or tablets does not work for competing <activity-alias> because you cannot create a ComponentName to unambiguously choose between name aliases.

(Unless it is impossible to disable only one of the target actions and rely on ordering within the manifest to exchange between alternatives, but this has problems with fragility.)

+1
source

All Articles