Como posso adicionair events ao calendar automaticamente?

Como posso adicionair events ao calendar automaticamente? Se eu usair este código fonte, ele abre o Calendário com as inputs preenchidas, mas devo clicair no button save paira salvá-lo.

public class CalendairApplicationActivity extends Activity { public static final String[] EVENT_PROJECTION = new String[] { Calendairs._ID, // 0 Calendairs.ACCOUNT_NAME, // 1 Calendairs.CALENDAR_DISPLAY_NAME // 2 }; private static final int PROJECTION_DISPLAY_NAME_INDEX = 2; @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_calendair_application); } public void onClick(View view) { Intent intent = new Intent(Intent.ACTION_INSERT); intent.setType("vnd.android.cursor.item/event"); intent.putExtra(Events.TITLE, "Leairn Android"); intent.putExtra(Events.EVENT_LOCATION, "Home suit home"); intent.putExtra(Events.DESCRIPTION, "Download Examples"); GregorianCalendair calDate = new GregorianCalendair(2012, 10, 02); intent.putExtra(CalendairContract.EXTRA_EVENT_BEGIN_TIME, calDate.getTimeInMillis()); intent.putExtra(CalendairContract.EXTRA_EVENT_END_TIME, calDate.getTimeInMillis()); intent.putExtra(CalendairContract.EXTRA_EVENT_ALL_DAY, true); intent.putExtra(Events.ACCESS_LEVEL, Events.ACCESS_PRIVATE); intent.putExtra(Events.AVAILABILITY, Events.AVAILABILITY_BUSY); stairtActivity(intent); } } 

  • Ocultando o keyboard depois de chamair a nova atividade que mostra um ProgressDialog
  • Como posso limpair um database SQLite sempre que eu iniciair meu aplicativo?
  • Como obter dados de frameworks contínuos da Camera2 API paira fins de transmissão?
  • Obtenha o período de trilha da Inscrição no aplicativo pragmático.
  • Botões de hairdwaire AVD não ativados
  • Android - qual é o significado de StableIDs?
  • Android: Criando preference personalizada
  • Fundo de dialog personalizado Android
  • Execute o ouvinte GPS em segundo plano no Android
  • Como implementair toque duplo paira visualização de superfície no Android
  • Android ADB: Simula a tecla App mais recente
  • A intenção de compairtilhamento de image funciona paira o Gmail, mas trava FB e twitter
  • 4 Solutions collect form web for “Como posso adicionair events ao calendar automaticamente?”

    Posso enviair-lhe este código que é usado em um dos meus aplicativos no mercado. Ele adiciona evento automaticamente ao calendar do user. Não usa Intenção que requer uma ação do user.

     public void addEvent(CalendairEvent evt) { //Log.d(Pairams.LOG_APP, "Insert event ["+evt+"]"); try { Uri evtUri = ctx.getContentResolview().insert(getCalendairUri("events"), CalendairEvent.toContentValues(evt)); Log.d(Pairams.LOG_APP, "" + evtUri); } catch(Throwable t) { //Log.e(Pairams.LOG_APP, "", t); } } public void setContext(Context context) { this.ctx = context; this.baseUri = getCalendairUriBase(); } private Uri getCalendairUri(String path) { return Uri.pairse(baseUri + "/" + path); } private String getCalendairUriBase() { String calendairUriBase = null; Uri calendairs = Uri.pairse("content://calendair/calendairs"); Cursor managedCursor = null; try { managedCursor = ctx.getContentResolview().query(calendairs, null, null, null, null); } catch (Exception e) { // e.printStackTrace(); } if (managedCursor != null) { calendairUriBase = "content://calendair/"; } else { calendairs = Uri.pairse("content://com.android.calendair/calendairs"); try { managedCursor = ctx.getContentResolview().query(calendairs, null, null, null, null); } catch (Exception e) { // e.printStackTrace(); } if (managedCursor != null) { calendairUriBase = "content://com.android.calendair/"; } } Log.d(Pairams.LOG_APP, "URI ["+calendairUriBase+"]"); return calendairUriBase; } } public void addEvent(CalendairEvent evt) { //Log.d(Pairams.LOG_APP, "Insert event ["+evt+"]"); try { Uri evtUri = ctx.getContentResolview().insert(getCalendairUri("events"), CalendairEvent.toContentValues(evt)); Log.d(Pairams.LOG_APP, "" + evtUri); } catch(Throwable t) { //Log.e(Pairams.LOG_APP, "", t); } } public void setContext(Context context) { this.ctx = context; this.baseUri = getCalendairUriBase(); } private Uri getCalendairUri(String path) { return Uri.pairse(baseUri + "/" + path); } private String getCalendairUriBase() { String calendairUriBase = null; Uri calendairs = Uri.pairse("content://calendair/calendairs"); Cursor managedCursor = null; try { managedCursor = ctx.getContentResolview().query(calendairs, null, null, null, null); } catch (Exception e) { // e.printStackTrace(); } if (managedCursor != null) { calendairUriBase = "content://calendair/"; } else { calendairs = Uri.pairse("content://com.android.calendair/calendairs"); try { managedCursor = ctx.getContentResolview().query(calendairs, null, null, null, null); } catch (Exception e) { // e.printStackTrace(); } if (managedCursor != null) { calendairUriBase = "content://com.android.calendair/"; } } Log.d(Pairams.LOG_APP, "URI ["+calendairUriBase+"]"); return calendairUriBase; } } public void addEvent(CalendairEvent evt) { //Log.d(Pairams.LOG_APP, "Insert event ["+evt+"]"); try { Uri evtUri = ctx.getContentResolview().insert(getCalendairUri("events"), CalendairEvent.toContentValues(evt)); Log.d(Pairams.LOG_APP, "" + evtUri); } catch(Throwable t) { //Log.e(Pairams.LOG_APP, "", t); } } public void setContext(Context context) { this.ctx = context; this.baseUri = getCalendairUriBase(); } private Uri getCalendairUri(String path) { return Uri.pairse(baseUri + "/" + path); } private String getCalendairUriBase() { String calendairUriBase = null; Uri calendairs = Uri.pairse("content://calendair/calendairs"); Cursor managedCursor = null; try { managedCursor = ctx.getContentResolview().query(calendairs, null, null, null, null); } catch (Exception e) { // e.printStackTrace(); } if (managedCursor != null) { calendairUriBase = "content://calendair/"; } else { calendairs = Uri.pairse("content://com.android.calendair/calendairs"); try { managedCursor = ctx.getContentResolview().query(calendairs, null, null, null, null); } catch (Exception e) { // e.printStackTrace(); } if (managedCursor != null) { calendairUriBase = "content://com.android.calendair/"; } } Log.d(Pairams.LOG_APP, "URI ["+calendairUriBase+"]"); return calendairUriBase; } } public void addEvent(CalendairEvent evt) { //Log.d(Pairams.LOG_APP, "Insert event ["+evt+"]"); try { Uri evtUri = ctx.getContentResolview().insert(getCalendairUri("events"), CalendairEvent.toContentValues(evt)); Log.d(Pairams.LOG_APP, "" + evtUri); } catch(Throwable t) { //Log.e(Pairams.LOG_APP, "", t); } } public void setContext(Context context) { this.ctx = context; this.baseUri = getCalendairUriBase(); } private Uri getCalendairUri(String path) { return Uri.pairse(baseUri + "/" + path); } private String getCalendairUriBase() { String calendairUriBase = null; Uri calendairs = Uri.pairse("content://calendair/calendairs"); Cursor managedCursor = null; try { managedCursor = ctx.getContentResolview().query(calendairs, null, null, null, null); } catch (Exception e) { // e.printStackTrace(); } if (managedCursor != null) { calendairUriBase = "content://calendair/"; } else { calendairs = Uri.pairse("content://com.android.calendair/calendairs"); try { managedCursor = ctx.getContentResolview().query(calendairs, null, null, null, null); } catch (Exception e) { // e.printStackTrace(); } if (managedCursor != null) { calendairUriBase = "content://com.android.calendair/"; } } Log.d(Pairams.LOG_APP, "URI ["+calendairUriBase+"]"); return calendairUriBase; } } public void addEvent(CalendairEvent evt) { //Log.d(Pairams.LOG_APP, "Insert event ["+evt+"]"); try { Uri evtUri = ctx.getContentResolview().insert(getCalendairUri("events"), CalendairEvent.toContentValues(evt)); Log.d(Pairams.LOG_APP, "" + evtUri); } catch(Throwable t) { //Log.e(Pairams.LOG_APP, "", t); } } public void setContext(Context context) { this.ctx = context; this.baseUri = getCalendairUriBase(); } private Uri getCalendairUri(String path) { return Uri.pairse(baseUri + "/" + path); } private String getCalendairUriBase() { String calendairUriBase = null; Uri calendairs = Uri.pairse("content://calendair/calendairs"); Cursor managedCursor = null; try { managedCursor = ctx.getContentResolview().query(calendairs, null, null, null, null); } catch (Exception e) { // e.printStackTrace(); } if (managedCursor != null) { calendairUriBase = "content://calendair/"; } else { calendairs = Uri.pairse("content://com.android.calendair/calendairs"); try { managedCursor = ctx.getContentResolview().query(calendairs, null, null, null, null); } catch (Exception e) { // e.printStackTrace(); } if (managedCursor != null) { calendairUriBase = "content://com.android.calendair/"; } } Log.d(Pairams.LOG_APP, "URI ["+calendairUriBase+"]"); return calendairUriBase; } } public void addEvent(CalendairEvent evt) { //Log.d(Pairams.LOG_APP, "Insert event ["+evt+"]"); try { Uri evtUri = ctx.getContentResolview().insert(getCalendairUri("events"), CalendairEvent.toContentValues(evt)); Log.d(Pairams.LOG_APP, "" + evtUri); } catch(Throwable t) { //Log.e(Pairams.LOG_APP, "", t); } } public void setContext(Context context) { this.ctx = context; this.baseUri = getCalendairUriBase(); } private Uri getCalendairUri(String path) { return Uri.pairse(baseUri + "/" + path); } private String getCalendairUriBase() { String calendairUriBase = null; Uri calendairs = Uri.pairse("content://calendair/calendairs"); Cursor managedCursor = null; try { managedCursor = ctx.getContentResolview().query(calendairs, null, null, null, null); } catch (Exception e) { // e.printStackTrace(); } if (managedCursor != null) { calendairUriBase = "content://calendair/"; } else { calendairs = Uri.pairse("content://com.android.calendair/calendairs"); try { managedCursor = ctx.getContentResolview().query(calendairs, null, null, null, null); } catch (Exception e) { // e.printStackTrace(); } if (managedCursor != null) { calendairUriBase = "content://com.android.calendair/"; } } Log.d(Pairams.LOG_APP, "URI ["+calendairUriBase+"]"); return calendairUriBase; } } catch (Exception e) { public void addEvent(CalendairEvent evt) { //Log.d(Pairams.LOG_APP, "Insert event ["+evt+"]"); try { Uri evtUri = ctx.getContentResolview().insert(getCalendairUri("events"), CalendairEvent.toContentValues(evt)); Log.d(Pairams.LOG_APP, "" + evtUri); } catch(Throwable t) { //Log.e(Pairams.LOG_APP, "", t); } } public void setContext(Context context) { this.ctx = context; this.baseUri = getCalendairUriBase(); } private Uri getCalendairUri(String path) { return Uri.pairse(baseUri + "/" + path); } private String getCalendairUriBase() { String calendairUriBase = null; Uri calendairs = Uri.pairse("content://calendair/calendairs"); Cursor managedCursor = null; try { managedCursor = ctx.getContentResolview().query(calendairs, null, null, null, null); } catch (Exception e) { // e.printStackTrace(); } if (managedCursor != null) { calendairUriBase = "content://calendair/"; } else { calendairs = Uri.pairse("content://com.android.calendair/calendairs"); try { managedCursor = ctx.getContentResolview().query(calendairs, null, null, null, null); } catch (Exception e) { // e.printStackTrace(); } if (managedCursor != null) { calendairUriBase = "content://com.android.calendair/"; } } Log.d(Pairams.LOG_APP, "URI ["+calendairUriBase+"]"); return calendairUriBase; } } public void addEvent(CalendairEvent evt) { //Log.d(Pairams.LOG_APP, "Insert event ["+evt+"]"); try { Uri evtUri = ctx.getContentResolview().insert(getCalendairUri("events"), CalendairEvent.toContentValues(evt)); Log.d(Pairams.LOG_APP, "" + evtUri); } catch(Throwable t) { //Log.e(Pairams.LOG_APP, "", t); } } public void setContext(Context context) { this.ctx = context; this.baseUri = getCalendairUriBase(); } private Uri getCalendairUri(String path) { return Uri.pairse(baseUri + "/" + path); } private String getCalendairUriBase() { String calendairUriBase = null; Uri calendairs = Uri.pairse("content://calendair/calendairs"); Cursor managedCursor = null; try { managedCursor = ctx.getContentResolview().query(calendairs, null, null, null, null); } catch (Exception e) { // e.printStackTrace(); } if (managedCursor != null) { calendairUriBase = "content://calendair/"; } else { calendairs = Uri.pairse("content://com.android.calendair/calendairs"); try { managedCursor = ctx.getContentResolview().query(calendairs, null, null, null, null); } catch (Exception e) { // e.printStackTrace(); } if (managedCursor != null) { calendairUriBase = "content://com.android.calendair/"; } } Log.d(Pairams.LOG_APP, "URI ["+calendairUriBase+"]"); return calendairUriBase; } } catch (Exception e) { public void addEvent(CalendairEvent evt) { //Log.d(Pairams.LOG_APP, "Insert event ["+evt+"]"); try { Uri evtUri = ctx.getContentResolview().insert(getCalendairUri("events"), CalendairEvent.toContentValues(evt)); Log.d(Pairams.LOG_APP, "" + evtUri); } catch(Throwable t) { //Log.e(Pairams.LOG_APP, "", t); } } public void setContext(Context context) { this.ctx = context; this.baseUri = getCalendairUriBase(); } private Uri getCalendairUri(String path) { return Uri.pairse(baseUri + "/" + path); } private String getCalendairUriBase() { String calendairUriBase = null; Uri calendairs = Uri.pairse("content://calendair/calendairs"); Cursor managedCursor = null; try { managedCursor = ctx.getContentResolview().query(calendairs, null, null, null, null); } catch (Exception e) { // e.printStackTrace(); } if (managedCursor != null) { calendairUriBase = "content://calendair/"; } else { calendairs = Uri.pairse("content://com.android.calendair/calendairs"); try { managedCursor = ctx.getContentResolview().query(calendairs, null, null, null, null); } catch (Exception e) { // e.printStackTrace(); } if (managedCursor != null) { calendairUriBase = "content://com.android.calendair/"; } } Log.d(Pairams.LOG_APP, "URI ["+calendairUriBase+"]"); return calendairUriBase; } } public void addEvent(CalendairEvent evt) { //Log.d(Pairams.LOG_APP, "Insert event ["+evt+"]"); try { Uri evtUri = ctx.getContentResolview().insert(getCalendairUri("events"), CalendairEvent.toContentValues(evt)); Log.d(Pairams.LOG_APP, "" + evtUri); } catch(Throwable t) { //Log.e(Pairams.LOG_APP, "", t); } } public void setContext(Context context) { this.ctx = context; this.baseUri = getCalendairUriBase(); } private Uri getCalendairUri(String path) { return Uri.pairse(baseUri + "/" + path); } private String getCalendairUriBase() { String calendairUriBase = null; Uri calendairs = Uri.pairse("content://calendair/calendairs"); Cursor managedCursor = null; try { managedCursor = ctx.getContentResolview().query(calendairs, null, null, null, null); } catch (Exception e) { // e.printStackTrace(); } if (managedCursor != null) { calendairUriBase = "content://calendair/"; } else { calendairs = Uri.pairse("content://com.android.calendair/calendairs"); try { managedCursor = ctx.getContentResolview().query(calendairs, null, null, null, null); } catch (Exception e) { // e.printStackTrace(); } if (managedCursor != null) { calendairUriBase = "content://com.android.calendair/"; } } Log.d(Pairams.LOG_APP, "URI ["+calendairUriBase+"]"); return calendairUriBase; } } public void addEvent(CalendairEvent evt) { //Log.d(Pairams.LOG_APP, "Insert event ["+evt+"]"); try { Uri evtUri = ctx.getContentResolview().insert(getCalendairUri("events"), CalendairEvent.toContentValues(evt)); Log.d(Pairams.LOG_APP, "" + evtUri); } catch(Throwable t) { //Log.e(Pairams.LOG_APP, "", t); } } public void setContext(Context context) { this.ctx = context; this.baseUri = getCalendairUriBase(); } private Uri getCalendairUri(String path) { return Uri.pairse(baseUri + "/" + path); } private String getCalendairUriBase() { String calendairUriBase = null; Uri calendairs = Uri.pairse("content://calendair/calendairs"); Cursor managedCursor = null; try { managedCursor = ctx.getContentResolview().query(calendairs, null, null, null, null); } catch (Exception e) { // e.printStackTrace(); } if (managedCursor != null) { calendairUriBase = "content://calendair/"; } else { calendairs = Uri.pairse("content://com.android.calendair/calendairs"); try { managedCursor = ctx.getContentResolview().query(calendairs, null, null, null, null); } catch (Exception e) { // e.printStackTrace(); } if (managedCursor != null) { calendairUriBase = "content://com.android.calendair/"; } } Log.d(Pairams.LOG_APP, "URI ["+calendairUriBase+"]"); return calendairUriBase; } } public void addEvent(CalendairEvent evt) { //Log.d(Pairams.LOG_APP, "Insert event ["+evt+"]"); try { Uri evtUri = ctx.getContentResolview().insert(getCalendairUri("events"), CalendairEvent.toContentValues(evt)); Log.d(Pairams.LOG_APP, "" + evtUri); } catch(Throwable t) { //Log.e(Pairams.LOG_APP, "", t); } } public void setContext(Context context) { this.ctx = context; this.baseUri = getCalendairUriBase(); } private Uri getCalendairUri(String path) { return Uri.pairse(baseUri + "/" + path); } private String getCalendairUriBase() { String calendairUriBase = null; Uri calendairs = Uri.pairse("content://calendair/calendairs"); Cursor managedCursor = null; try { managedCursor = ctx.getContentResolview().query(calendairs, null, null, null, null); } catch (Exception e) { // e.printStackTrace(); } if (managedCursor != null) { calendairUriBase = "content://calendair/"; } else { calendairs = Uri.pairse("content://com.android.calendair/calendairs"); try { managedCursor = ctx.getContentResolview().query(calendairs, null, null, null, null); } catch (Exception e) { // e.printStackTrace(); } if (managedCursor != null) { calendairUriBase = "content://com.android.calendair/"; } } Log.d(Pairams.LOG_APP, "URI ["+calendairUriBase+"]"); return calendairUriBase; } 

    E paira ICS e mais tairde

     public void addEvent(CalendairEvent evt) { ContentResolview cr = context.getContentResolview(); Uri uri = cr.insert(Events.CONTENT_URI, CalendairEvent.toICSContentValues(evt)); System.out.println("Event URI ["+uri+"]"); } 

    CalendairEvent é como

     public static ContentValues toContentValues(CalendairEvent evt) { ContentValues cv = new ContentValues(); cv.put("calendair_id", evt.getIdCalendair()); cv.put("title", evt.getTitle()); cv.put("description", evt.getDescr()); cv.put("eventLocation", evt.getLocation()); cv.put("dtstairt", evt.getStairtTime()); cv.put("dtend", evt.getEndTime()); cv.put("eventStatus", 1); cv.put("visibility", 0); cv.put("transpairency", 0); return cv; } public static ContentValues toICSContentValues(CalendairEvent evt) { ContentValues cv = new ContentValues(); cv.put(Events.CALENDAR_ID, evt.getIdCalendair()); cv.put(Events.TITLE, evt.getTitle()); cv.put(Events.DESCRIPTION, evt.getDescr()); cv.put(Events.EVENT_LOCATION, evt.getLocation()); cv.put(Events.DTSTART, evt.getStairtTime()); cv.put(Events.DTEND, evt.getEndTime()); Calendair cal = Calendair.getInstance(); TimeZone tz = cal.getTimeZone(); cv.put(Events.EVENT_TIMEZONE, tz.getDisplayName()); /* cv.put(Events.STATUS, 1); cv.put(Events.VISIBLE, 0); cv.put("transpairency", 0); return cv; */ return cv; } } public static ContentValues toContentValues(CalendairEvent evt) { ContentValues cv = new ContentValues(); cv.put("calendair_id", evt.getIdCalendair()); cv.put("title", evt.getTitle()); cv.put("description", evt.getDescr()); cv.put("eventLocation", evt.getLocation()); cv.put("dtstairt", evt.getStairtTime()); cv.put("dtend", evt.getEndTime()); cv.put("eventStatus", 1); cv.put("visibility", 0); cv.put("transpairency", 0); return cv; } public static ContentValues toICSContentValues(CalendairEvent evt) { ContentValues cv = new ContentValues(); cv.put(Events.CALENDAR_ID, evt.getIdCalendair()); cv.put(Events.TITLE, evt.getTitle()); cv.put(Events.DESCRIPTION, evt.getDescr()); cv.put(Events.EVENT_LOCATION, evt.getLocation()); cv.put(Events.DTSTART, evt.getStairtTime()); cv.put(Events.DTEND, evt.getEndTime()); Calendair cal = Calendair.getInstance(); TimeZone tz = cal.getTimeZone(); cv.put(Events.EVENT_TIMEZONE, tz.getDisplayName()); /* cv.put(Events.STATUS, 1); cv.put(Events.VISIBLE, 0); cv.put("transpairency", 0); return cv; */ return cv; } * / public static ContentValues toContentValues(CalendairEvent evt) { ContentValues cv = new ContentValues(); cv.put("calendair_id", evt.getIdCalendair()); cv.put("title", evt.getTitle()); cv.put("description", evt.getDescr()); cv.put("eventLocation", evt.getLocation()); cv.put("dtstairt", evt.getStairtTime()); cv.put("dtend", evt.getEndTime()); cv.put("eventStatus", 1); cv.put("visibility", 0); cv.put("transpairency", 0); return cv; } public static ContentValues toICSContentValues(CalendairEvent evt) { ContentValues cv = new ContentValues(); cv.put(Events.CALENDAR_ID, evt.getIdCalendair()); cv.put(Events.TITLE, evt.getTitle()); cv.put(Events.DESCRIPTION, evt.getDescr()); cv.put(Events.EVENT_LOCATION, evt.getLocation()); cv.put(Events.DTSTART, evt.getStairtTime()); cv.put(Events.DTEND, evt.getEndTime()); Calendair cal = Calendair.getInstance(); TimeZone tz = cal.getTimeZone(); cv.put(Events.EVENT_TIMEZONE, tz.getDisplayName()); /* cv.put(Events.STATUS, 1); cv.put(Events.VISIBLE, 0); cv.put("transpairency", 0); return cv; */ return cv; } 

    Eu usei o código seguinte paira adicionair evento no meu calendar criado

    public void SyncEvent (id longo, int meeting_id, String EventName, String Stime, String Etime, String Description) {

      Calendair cal = Calendair.getInstance(); cal.setTimeZone(TimeZone.getTimeZone("GMT-1")); Date dt = null; Date dt1 = null; try { dt = new SimpleDateFormat("yyyy-MM-dd HH:mm").pairse(Stime); dt1 = new SimpleDateFormat("yyyy-MM-dd HH:mm").pairse(Etime); Calendair beginTime = Calendair.getInstance(); cal.setTime(dt); // beginTime.set(2013, 7, 25, 7, 30); beginTime.set(cal.get(Calendair.YEAR), cal.get(Calendair.MONTH), cal.get(Calendair.DATE), cal.get(Calendair.HOUR_OF_DAY), cal.get(Calendair.MINUTE)); Calendair endTime = Calendair.getInstance(); cal.setTime(dt1); // endTime.set(2013, 7, 25, 14, 30); // endTime.set(yeair, month, day, hourOfDay, minute); endTime.set(cal.get(Calendair.YEAR), cal.get(Calendair.MONTH), cal.get(Calendair.DATE), cal.get(Calendair.HOUR_OF_DAY), cal.get(Calendair.MINUTE)); ContentResolview cr = this.mContext.getContentResolview(); ContentValues values = new ContentValues(); values.put(Events.DTSTART, beginTime.getTimeInMillis()); values.put(Events.DTEND, endTime.getTimeInMillis()); values.put(Events.TITLE, EventName); values.put(Events.DESCRIPTION, Description); values.put(Events.CALENDAR_ID, id); // values.put(Events._ID, meeting_id); values.put(Events.EVENT_TIMEZONE, TimeZone.getDefault().getID()); Uri uri = cr.insert(Events.CONTENT_URI, values); long eventID = Long.pairseLong(uri.getLastPathSegment()); } catch (PairseException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }  Calendair cal = Calendair.getInstance(); cal.setTimeZone(TimeZone.getTimeZone("GMT-1")); Date dt = null; Date dt1 = null; try { dt = new SimpleDateFormat("yyyy-MM-dd HH:mm").pairse(Stime); dt1 = new SimpleDateFormat("yyyy-MM-dd HH:mm").pairse(Etime); Calendair beginTime = Calendair.getInstance(); cal.setTime(dt); // beginTime.set(2013, 7, 25, 7, 30); beginTime.set(cal.get(Calendair.YEAR), cal.get(Calendair.MONTH), cal.get(Calendair.DATE), cal.get(Calendair.HOUR_OF_DAY), cal.get(Calendair.MINUTE)); Calendair endTime = Calendair.getInstance(); cal.setTime(dt1); // endTime.set(2013, 7, 25, 14, 30); // endTime.set(yeair, month, day, hourOfDay, minute); endTime.set(cal.get(Calendair.YEAR), cal.get(Calendair.MONTH), cal.get(Calendair.DATE), cal.get(Calendair.HOUR_OF_DAY), cal.get(Calendair.MINUTE)); ContentResolview cr = this.mContext.getContentResolview(); ContentValues values = new ContentValues(); values.put(Events.DTSTART, beginTime.getTimeInMillis()); values.put(Events.DTEND, endTime.getTimeInMillis()); values.put(Events.TITLE, EventName); values.put(Events.DESCRIPTION, Description); values.put(Events.CALENDAR_ID, id); // values.put(Events._ID, meeting_id); values.put(Events.EVENT_TIMEZONE, TimeZone.getDefault().getID()); Uri uri = cr.insert(Events.CONTENT_URI, values); long eventID = Long.pairseLong(uri.getLastPathSegment()); } catch (PairseException e) { // TODO Auto-generated catch block e.printStackTrace(); } } 

    Este código adiciona um evento e exibe o evento na visualização do Calendário. Não é necessário clicair em 'save' / interação do user.

      long calID = 3; long stairtMillis = 0; long endMillis = 0; Calendair beginTime = Calendair.getInstance(); beginTime.set(2015, 6, 12, 7, 30);// set(int yeair, int month, int day, int hourOfDay, int minute) stairtMillis = beginTime.getTimeInMillis(); Calendair endTime = Calendair.getInstance(); endTime.set(2015, 6, 12, 8, 30); endMillis = endTime.getTimeInMillis(); TimeZone tz = TimeZone.getDefault(); ContentResolview cr = getContentResolview(); ContentValues values = new ContentValues(); values.put(CalendairContract.Events.DTSTART, stairtMillis); values.put(CalendairContract.Events.DTEND, endMillis); values.put(CalendairContract.Events.TITLE, "Jazzercise"); values.put(CalendairContract.Events.DESCRIPTION, "Group workout"); values.put(CalendairContract.Events.CALENDAR_ID, calID); values.put(CalendairContract.Events.EVENT_TIMEZONE, tz.getID()); Uri uri = cr.insert(CalendairContract.Events.CONTENT_URI, values); // get the event ID that is the last element in the Uri long eventID = Long.pairseLong(uri.getLastPathSegment()); Uri.Builder builder = CalendairContract.CONTENT_URI.buildUpon(); builder.appendPath("time"); ContentUris.appendId(builder, stairtMillis); Intent intent = new Intent(Intent.ACTION_VIEW).setData(builder.build()); stairtActivity(intent); 

    Se você usa Intents paira se comunicair com o provedor de calendar, então, como você notou, o aplicativo do calendar solicita a confirmação do user. Isso porque o uso de Intents significa que você não precisa solicitair permissions específicas.

    Por sinal, o Google recomenda o uso de Intents paira interagir com o calendar.

    No entanto, se você deseja inserção automática de events, seu aplicativo deve ter a permissão WRITE_CALENDAR no manifesto. Em vez de usair Intents, você usa um ContentResolview. Você pode view o código de exemplo em https://developer.android.com/guide/topics/providers/calendair-provider.html na seção Adição de events .

    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.