1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
try {
// utiliser des noms de variable qui veulent dire quelque chose
String dateDebutStr = in4.getStringExtra(KEY_DATE);
String dateFinStr = in4.getStringExtra(KEY_DATE2);
Log.v("MaFonction","Date-debut: '"+dateDebutStr+"', Date-Fin: '"+dateFinStr+"'");
// static uniquement si le code est dans un seul thread comme l'UI... SimpleDateFormat n'étant pas réentrant
static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date dateDebut = sdf.parse(dateDebutStr);
Date dateFin = sdf.parse(dateFinStr);
Log.v("MaFonction","Debut: "+dateDebut +", Fin: '"+dateFin);
if (Build.VERSION.SDK_INT >= 14) {
Intent intent8 = new Intent(Intent.ACTION_INSERT,Events.CONTENT_URI);
intent8.setType("vnd.android.cursor.item/event");
intent8.putExtra(Events.TITLE, name);
intent8.putExtra(Events.EVENT_LOCATION, adresse2);
intent8.putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME,
dateDebut.getTime());
intent8.putExtra(CalendarContract.EXTRA_EVENT_END_TIME, dateFin.getTime());
intent8.putExtra(Events.ACCESS_LEVEL, Events.ACCESS_PRIVATE);
intent8.putExtra(Events.AVAILABILITY, Events.AVAILABILITY_BUSY);
startActivity(intent8);
}
// sinon on fait quoi ?
} catch (Exception ex) {
Log.e("MaFonction","Erreur de d'insertion d'évenement !",ex);
} |
Partager