Fragezum Kalender Eintrag

kukuk

kukuk

App-Anbieter (kostenlos)
29
Hallo ich erstelle einen Kalender Eintrag mit folgendem Code:

Ich habe jetzt das Problem, das wenn im TimePicker Dialog 12Uhr irgendwas ausgewählt wird, das der Kaleder Eintrag bei 0 Uhr irgendwas gesetzt wird.
Kann mir da jemand helfen?
Wenn ich die TimeZone auslesen (TimeZone.getDefault().getDisplayName()) bekomm ich als Meldung Mittel Europäische Normalzeit.

Und noch ne Frage ich möchte ein values.put(Events.HAS_ALARM, ....);
setzen, das 30min bevor der Termin starten die Kalender Meldung erscheint.


Code:
 java.util.Date parsedDate1 = null;
                                     
                                 Toast.makeText(KontaktBearbeiten.this, "" +datum_uhrzeit, Toast.LENGTH_SHORT).show();
                                     SimpleDateFormat dateFormat = new SimpleDateFormat("dd.MM.yyy hh:mm:ss");
                                     try {
                                     parsedDate1 = dateFormat.parse(datum_uhrzeit);
                                     
                                     } catch (Exception e) {
                                         e.printStackTrace();
                                     }
SetCalenderEntry(calendar_start_time,calendar_eventLocation,calendar_title,calendar_description   );

        private void SetCalenderEntry(long date,String location,String title,String description)
                             {

                             
                             
                              ContentResolver cr = getContentResolver();
                              ContentValues values = new ContentValues();
                              values.put(Events.DTSTART, date);
                              values.put(Events.DTEND, date);
                              values.put(Events.TITLE, title);
                              values.put(Events.EVENT_LOCATION, location);
                              values.put(Events.DESCRIPTION, description);
                              values.put(Events.CALENDAR_ID, 1);
                              values.put(Events.EVENT_TIMEZONE, TimeZone.getDefault().getDisplayName());
                              Uri uri = cr.insert(CalendarContract.Events.CONTENT_URI, values);
                              
                             Toast.makeText(KontaktBearbeiten.this, "" +TimeZone.getDefault().getDisplayName(), Toast.LENGTH_SHORT).show();
                             }


Der ursprüngliche Beitrag von 16:26 Uhr wurde um 17:29 Uhr ergänzt:

Das mit dem Reminder habe ich selber gelöst:

Ich poste mal den Code falls noch jemand das Problem hat:

Code:
SetCalenderEntry(calendar_start_time,calendar_eventLocation,calendar_title,calendar_description   );






                              private String getCalendarUriBase(Activity act) {
                                     String calendarUriBase = null;
                                     Uri calendars = Uri.parse("content://calendar/calendars");
                                     Cursor managedCursor = null;
                                     try {
                                         managedCursor = act.managedQuery(calendars, null, null, null, null);
                                     } catch (Exception e) {
                                     }
                                     if (managedCursor != null) {
                                         calendarUriBase = "content://calendar/";
                                     } else {
                                         calendars = Uri.parse("content://com.android.calendar/calendars");
                                         try {
                                             managedCursor = act.managedQuery(calendars, null, null, null, null);
                                         } catch (Exception e) {
                                         }
                                         if (managedCursor != null) {
                                             calendarUriBase = "content://com.android.calendar/";
                                         }
                                     }
                                     return calendarUriBase;
                                 }
                             
                             private void SetCalenderEntry(long date,String location,String title,String description)
                             {

                             
                             
                              ContentResolver cr = getContentResolver();
                              ContentValues values = new ContentValues();
                              values.put(Events.DTSTART, date);
                              values.put(Events.DTEND, date);
                              values.put(Events.TITLE, title);
                              values.put(Events.EVENT_LOCATION, location);
                              values.put(Events.DESCRIPTION, description);
                              values.put(Events.CALENDAR_ID, 1);
                              values.put(Events.HAS_ALARM, 1);
                              

                              values.put(Events.EVENT_TIMEZONE, TimeZone.getDefault().getDisplayName());
                             
                              Uri uri = cr.insert(CalendarContract.Events.CONTENT_URI, values);
                              
                              
                             Uri REMINDERS_URI = Uri.parse(getCalendarUriBase(this) + "reminders");
                             values = new ContentValues();
                             values.put( "event_id", Long.parseLong(uri.getLastPathSegment()));
                             values.put( "method", 1 );
                             values.put( "minutes", 30 );
                             cr.insert( REMINDERS_URI, values );
                              
                             //Toast.makeText(KontaktBearbeiten.this, "" +TimeZone.getDefault().getDisplayName(), Toast.LENGTH_SHORT).show();
                             }


Der ursprüngliche Beitrag von 17:29 Uhr wurde um 17:44 Uhr ergänzt:

Problem mit dem das wenn man 12 uhr auswählt ein Eintrag bei 0 Uhr gesetzt wird auch hinbekommen:
Vorher:
Code:
  SimpleDateFormat dateFormat = new SimpleDateFormat("dd.MM.yyy hh:mm:ss");

Nachher:
Code:
  SimpleDateFormat dateFormat = new SimpleDateFormat("dd.MM.yyy HH:mm:ss");
 
Zuletzt bearbeitet:

Ähnliche Themen

S
Antworten
17
Aufrufe
551
jogimuc
J
D
Antworten
4
Aufrufe
1.120
jogimuc
J
L
Antworten
2
Aufrufe
966
louisbgt
L
Zurück
Oben Unten