Calendar in an Android app

0

I'm trying to develop in my android app, a functionality from where I can query, sign up, events etc in a calendar. I tried the CalendarView and got to the point of clicking a date and triggering an event. My question is as follows. Would you have a simpler way of doing this using GoogleCalendar? How do I put a mark on the date where the event was created to know that there is something registered on that day? I gave a read on Google calendar but I was a bit confused. I'm new to android and I need help. Obridado

    
asked by anonymous 26.08.2014 / 13:44

2 answers

3

You can open the calendar window as follows:

Intent intent = new Intent(Intent.ACTION_INSERT);
intent.setData(CalendarContract.Events.CONTENT_URI);
startActivity(intent);

If you need to add dates use the following:

//Cria uma intent para abertura de uma nova activity.
Intent intent = new Intent(Intent.ACTION_INSERT);
intent.setType("vnd.android.cursor.item/event");

//Configurações do evento.
intent.putExtra(Events.TITLE, "Teste de Titulo");
intent.putExtra(Events.EVENT_LOCATION, "Local do evento");
intent.putExtra(Events.DESCRIPTION, "Teste de descrição");

//Configuração de data do evento
GregorianCalendar calDate = new GregorianCalendar(2014, 28, 08);
intent.putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME,
calDate.getTimeInMillis());
intent.putExtra(CalendarContract.EXTRA_EVENT_END_TIME,
calDate.getTimeInMillis());

//Marca o evento como dia inteiro.
intent.putExtra(CalendarContract.EXTRA_EVENT_ALL_DAY, true);

//Define se será repetido
intent.putExtra(Events.RRULE, "FREQ=WEEKLY;COUNT=11;WKST=SU;BYDAY=TU,TH");

//Marca como privado e como ocupado.
intent.putExtra(Events.ACCESS_LEVEL, Events.ACCESS_PRIVATE);
intent.putExtra(Events.AVAILABILITY, Events.AVAILABILITY_BUSY); 

If you want to use within your application, you will have to do it differently. There is this library of third parties that I find very interesting and beautiful, it can help you.

link

Hug.

    
26.08.2014 / 15:45
0

I do not know if that's what you need, but I also had to work with the calendar and I found this library very good:

link

final CollapsibleCalendar collapsibleCalendar = findViewById(R.id.calendarView);
    collapsibleCalendar.setCalendarListener(new CollapsibleCalendar.CalendarListener() {

        @Override
        public void onDaySelect() {
            Day day = viewCalendar.getSelectedDay();
            Log.i(getClass().getName(), "Selected Day: "
                    + day.getYear() + "/" + (day.getMonth() + 1) + "/" + day.getDay());
        }

        @Override
        public void onItemClick(View view) {

        }

        @Override
        public void onDataUpdate() {

        }

        @Override
        public void onMonthChange() {

        }

        @Override
        public void onWeekChange(int i) {

        }
    });
    
04.06.2018 / 02:45