Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I managed to produce a work around to this problem today by piecing together different bits of advice found on SO and the wider web.</p> <p>Basically I use a caretaker called <strong>CallendarAccess</strong>, and two classes with the same public method structure, one called <strong>CalendarLT14</strong> in which the method calls resolve to the old undocumented way, and <strong>CalendarGTE14</strong> which utilised the correct Android V14+way of doing things. </p> <p>Both these classes extend a self written abstract class called <strong>CalendarService</strong> which contain abstract methods common to the public ones of <strong>CalendarLT14</strong> and <strong>CalendarGTE14</strong>.</p> <p>A problem in doing this is that Android versions less than IceCreamSandwich (v14) will not compile code such as <strong>CalendarContract callendarContact;</strong> which is written for later versions. To resolve this one sets the in the manifest the target version to 14 (Android 4.0), but the minimum version to 7 (android 2.1).This means the code 4.0 compiles and presents no problem to early versions because it is never invoked. Example method of the caretaker below.</p> <pre><code>public CalendarService getInstance() { if (Build.VERSION.SDK_INT &gt;= 14) return CalendarGTE14(context) else return CalendarLT14 } </code></pre> <p>This solution means the caretaker can selectively return an object which will resolve to the correct code relevant to the Android version in use and completely transparently to the programmer making calls to the caretaker or <strong>CalendarService</strong> class.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload