How to use the CalendarContract class in level 8 API

After running Android 4, the class CalendarContractenters the event entry into the device calendar. But if I created my application using API level 8 and now I want to use this class CalendarContractin my project using API level 8, because at API level 8 I use an undocumented API to write events to the device’s calendar and this doen 'code t work for android 4. So you can use the class CalendarContractin my project without changing the sdk version in the manifest file, because if I change the sdk version to 14, then this will allow me to use the classCalendarContractand by which I can solve the problem for Android 4. But at the same time, my application did not start in api 8 -13 and which I do not want to do, because my application works in the market. So, is there any way to solve this problem. Please explain me an example.

+5
source share
3 answers

Find a way to search for the api level programmatically ... if you can possibly use the appropriate code for the api level levels ... can this help programmatically get the Android API level of the device?

0
source

You cannot use CalendarContracton Android devices running below API level 14.

+3
source

, , SO .

CallendarAccess , CalendarLT14, , CalendarGTE14, Android V14 +.

CalendarService, , CalendarLT14 CalendarGTE14.

, Android, IceCreamSandwich (v14), , CalendarContract callendarContact;, . , 14 (Android 4.0), - 7 (android 2.1). , 4.0 , . .

public CalendarService getInstance()
{
   if (Build.VERSION.SDK_INT >= 14)
           return CalendarGTE14(context)
    else
           return CalendarLT14
}

, , , Android, , CalendarService.

+3

All Articles