1

I have built a CalDAV/CardDAV server in PHP. The next step is to create an Android client (can't use existing ones).

I have never developed for Android before, so I am looking for the best approach for this kind of project.

I have read through http://developer.android.com, but am still a little fuzzy. The biggest question I have is: Does it makes sense to reuse the existing calendar/contact applications in Android or roll my own?

  • I want my sync features/settings accessible from the same screen as the calendar/contacts. Is this possible with the default calendar/contacts applications (ie, some sort of plugin)
  • Short story is that data retrieved from/pushed to the CalDAV/CardDAV server will be in the .ics and .vcf formats. I am a little unclear on how this will work with "Content Providers".

So on a sync, will data be pulled from the server in .ics/.vcf, mapped to a "Content Provider", saved? Or vice versa, will newly saved data to the Content Provider will be converted to .ics/.vcf, and then pushed to the server?

penguin egg
  • 1,154
  • 2
  • 10
  • 20
  • I think your question is too general, reading Android developer docs first will help. – StarPinkER Feb 16 '13 at 03:18
  • @JermaineXu Thanks, I see your point. I removed a lot of the "general" Android development questions. I am still really just curious about how calendar and contact data works on the Android and if it were to be a bad idea to use .ics and .vcf formats. – penguin egg Feb 16 '13 at 23:33
  • @JermaineXu I have edited the question after some more reading through the Android documentation. Hopefully this is a little less broad. – penguin egg Feb 19 '13 at 20:32

1 Answers1

2

Does it makes sense to reuse the existing calendar/contact applications in Android or roll my own?

Definitely, if you don't reuse these two apps, perhaps user won't choose to install your app.

Is this possible with the default calendar/contacts applications (ie, some sort of plugin)

Yes, it is possible, there are two permissions to read/write calendar.

android.permission.READ_CALENDAR
android.permission.WRITE_CALENDAR

WRITE_CALENDAR Allows an application to write the user's calendar data.

Put these permissions into your AndroidManifest.xml. Then you will be able to manipulate the content provider used by the default calendar app.

calanderURL = "content://com.android.calendar/calendars";  //Calendar
calanderEventURL = "content://com.android.calendar/events";  //Events
calanderRemiderURL = "content://com.android.calendar/reminders"; //Reminders

There are many tutorials like Working with the Android Calendar on how to work with calendar.

For contact, it is similar. Two permissions:

android.permission.READ_CONTACTS
android.permission.WRITE_CONTACTS

Content Provider:

ContactsContract.RawContacts.CONTENT_URI

Tutorials:

Contacts Provider

Short story is that data retrieved from/pushed to the CalDAV/CardDAV server will be in the .ics and .vcf formats. I am a little unclear on how this will work with "Content Providers".

You need to export the data in those two content providers to your .ics and .vcf format. Take Contacts for example: how to create one .vcf file for all the contact in android

Community
  • 1
  • 1
StarPinkER
  • 14,081
  • 7
  • 55
  • 81
  • Thank you very much for the answer. I have one clarification though. I read about how you can put those permissions in your app to allow you to read/write. But I am wondering if there is anyway to call my sync app from the default calendar? For example, the user is browsing the calendar, and they want to perform a manual sync to the server. Is it possible to add some sort of plugin to the default calendar app to allow this? – penguin egg Feb 20 '13 at 06:27
  • 1
    Oh, unless you have an exchange server, it is impossible to change the behavior of the existing pre-installed application. But I think may be you can sync data with google, the pre-installed app can sync calendar from google. – StarPinkER Feb 20 '13 at 06:30
  • @JeramineXu I plan to support below Android 4.0 so I will not be using the Calendaring API introduced in SDK 14. Knowing that, if I store data for my calendar app in the default calendar uri (content://calendar/calendars), does that mean other calendar apps will be able to access my calendar data? Can I prevent other calendar apps from accessing it or do I need to create my own content provider? – penguin egg Feb 26 '13 at 02:48
  • 1
    Yes, other apps can access your calendar if you store your data into the default contentprovider. Your app can read/write it, why other apps cannot? If you want to prevent this behavior, you have to create your own content provider. – StarPinkER Feb 26 '13 at 02:53
  • The reason I don't want other apps to access my calendar data is because my calendar app will be syncing the calendar data to my CalDAV server. So I am assuming that in order to keep track of local changes on the Android device to push to the server, edits to calendar data could not happen from another calendar app. They would have to happen in my app so I can keep track of changes? Unless I am overlooking something with SyncAdapter. – penguin egg Feb 26 '13 at 02:56
  • This is not possible if you want reuse the current calendar app. But I think maybe you can make a local copy of data yourself, and sync it with your server, and perform an svn-like change detection. – StarPinkER Feb 26 '13 at 04:25