Frage

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?

War es hilfreich?

Lösung

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

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top