Reputation: 1967
The application have some activities, some runs on higher version only. But since the activity support mimeType
of intent-filter
, so I've no control over its launch.
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>
Like the activity having this intent-filter
can be launched by lowered version than it must not. Eg : The activity must run in version 11 and above but android will still show it inside chooser dialog of image in lower versions. Is there a way to avoid this situation ?
Upvotes: 1
Views: 335
Reputation: 2303
If you're looking for only XML configuration I can suggest you the way, how it's done in Android API Demos.
They declare Activity
in the AndroidManifest as disabled or enabled depending on API version like this android:enabled="@bool/atLeastHoneycomb"
, where @bool/atLeastHoneycomb
is just a flag that is set to true in values-v11
and to false in the default values
folder (you can check Android API Demos, as I said previously, for more details).
Upvotes: 2
Reputation: 76458
You would have to have a 'controller' activity with the intent-filter
.
When this activity starts, it would check the current SDK level and then forward on the Intent to either the lower or higher SDK activity, then finish()
itself.
In your situation this can give you further flexibility later, say you want to direct tablets to a 3rd activity.
Another argument could be that your Activity should test the SDK level and then just swap Fragments
out dependent on this. i.e. your Activity is SDK agnostic but it is a controller for the correct Fragments to show.
References:
http://developer.android.com/training/basics/supporting-devices/platforms.html http://developer.android.com/training/basics/supporting-devices/platforms.html#version-codes
http://developer.android.com/training/backward-compatible-ui/abstracting.html
http://developer.android.com/training/backward-compatible-ui/using-component.html
As you see from the references, you should go read the training docs
Upvotes: 2