title: call requires permission for Content URI in Calender
body: <p>I am quite new to android.I am developing one App in Which I ant to set events automatically.
  this is my Code ,I am referring <a href="http://developer.android.com/guide/topics/providers/calendar-provider.html" rel="nofollow noreferrer">http://developer.android.com/guide/topics/providers/calendar-provider.html</a></p>
  
  <pre><code>public boolean setReminder(int SelectedHour,int SelectedMinute,int NewHour,int NewMinute)
  {
      try{
          long calID = 3;
          long startMillis = 0;
          long endMillis = 0;
          Calendar StartTime = Calendar.getInstance();
          StartTime.set(StartTime.YEAR,StartTime.MONTH,StartTime.DAY_OF_MONTH,SelectedHour,SelectedMinute);
          startMillis = StartTime.getTimeInMillis();
          Calendar EndTime = Calendar.getInstance();
          int NewMonth = StartTime.MONTH+1;int NewDay = StartTime.DAY_OF_MONTH;
          EndTime.set(StartTime.YEAR,NewMonth,NewDay,NewHour,NewMinute);
          endMillis = EndTime.getTimeInMillis();
  
          TimeZone tz = TimeZone.getDefault();
  
          ContentResolver cr = getContentResolver();
          ContentValues values = new ContentValues();
          values.put(CalendarContract.Events.DTSTART, startMillis);
          values.put(CalendarContract.Events.DTEND, endMillis);
          values.put(CalendarContract.Events.TITLE, "Jazzercise");
          values.put(CalendarContract.Events.DESCRIPTION, "Group workout");
          values.put(CalendarContract.Events.CALENDAR_ID, calID);
          values.put(CalendarContract.Events.EVENT_TIMEZONE,  tz.getID());
          //Getting Problem in Line Below 
          Uri uri = cr.insert(CalendarContract.Events.CONTENT_URI,values);
          // get the event ID that is the last element in the Uri
          long eventID = Long.parseLong(uri.getLastPathSegment());
  
  
          Uri.Builder builder = CalendarContract.CONTENT_URI.buildUpon();
          builder.appendPath("time");
          ContentUris.appendId(builder, startMillis);
          Intent intent = new Intent(Intent.ACTION_VIEW).setData(builder.build());
          startActivity(intent);
     return true;
      }
      catch (Exception ex)
      {
          ex.printStackTrace();
          return false;
      }
  </code></pre>
  
  <p>I am getting <strong>RedMark</strong> below the Line </p>
  
  <pre><code>Uri uri = cr.insert(CalendarContract.Events.CONTENT_URI,values);
  </code></pre>
  
  <p>error is saying
  <strong>Call requires permission which may be rejected by user.code should explicitly check to see if permission is available...</strong></p>
  
  <p>I hav already added permissions like <strong>android.permission.ACCESS_FINE_LOCATION</strong> and <strong>android.permission.ACCESS_COARSE_LOCATION</strong> in my manifest File</p>
  
  <p>though my Application runs but when i call the Calender Intent it gives me <strong><em>Webpage Not Availble</em></strong>.</p>
  
  <p>I also tried like <a href="https://stackoverflow.com/questions/10412074/adding-events-date-and-time-in-android-calendar">Adding events date and time in android calendar</a></p>
  
  <p>but still its not working.</p>
  
  <p>thanks in advance..</p>