0

I have a BroadcastReciever with an intent filter for calendar changes along with other intent filters.

    <receiver android:name=".AppBroadcastReceiver">
        <intent-filter>
            <action android:name="android.intent.action.PROVIDER_CHANGED" />
            <data android:scheme="content" />
            <data android:host="com.android.calendar" />
        </intent-filter>
        ...
    </receiver>

Is it possible to disable the intent filter based on the SDK version? With SDK 24 and later, I should use JobScheduler instead.

cambunctious
  • 8,391
  • 5
  • 34
  • 53
  • Add version check in the `onReceive()` of the broadcaster – Ashutosh Sagar Sep 16 '19 at 03:51
  • you can refer this- https://stackoverflow.com/questions/40505357/disable-the-intent-filter-from-android-manifest-programatically – Faizzy Sep 16 '19 at 03:57
  • @MohdFaizan that seems to only apply to activities – cambunctious Sep 16 '19 at 04:17
  • @AshutoshSagar that's really not ideal since the app would be launched an extra time evey time the calendar changes – cambunctious Sep 16 '19 at 04:18
  • I don't see why we have to launch the app again @cambunctious. As If places series of Check for various versions it shouldn't be a problem. If you don't want to do something in a particular SDK version, then make a check for it and leave it empty or put it in else case. – Ashutosh Sagar Sep 17 '19 at 03:56
  • @AshutoshSagar Android launches the app whenever a matching intent is broadcasted and the app is not already running. I'm looking for a way to prevent the app being launched altogether for certain intent filters on certain SDK versions. I don't think that is over-optimizing. – cambunctious Sep 17 '19 at 20:10

0 Answers0