1
Google 캘린더 API를 사용하여 이벤트, 날짜 및 시간을 표시하는 데 효과적입니다. Google 캘린더에서 일정을 삭제하는 방법을 알고 싶습니다.android에서 Google 캘린더 이벤트 삭제
private class MakeRequestTask extends AsyncTask<Void, Void, List<String>> {
private com.google.api.services.calendar.Calendar mService = null;
private Exception mLastError = null;
public MakeRequestTask(GoogleAccountCredential credential) {
HttpTransport transport = AndroidHttp.newCompatibleTransport();
JsonFactory jsonFactory = JacksonFactory.getDefaultInstance();
mService = new com.google.api.services.calendar.Calendar.Builder(
transport, jsonFactory, credential)
.setApplicationName("Google Calendar API Android Quickstart")
.build();
}
@Override
protected List<String> doInBackground(Void... params) {
try {
return getDataFromApi();
} catch (Exception e) {
mLastError = e;
cancel(true);
return null;
}
}
private List<String> getDataFromApi() throws IOException {
// List the next 10 events from the primary calendar.
DateTime now = new DateTime(System.currentTimeMillis());
List<String> eventStrings = new ArrayList<String>();
Events events = mService.events().list("primary")
.setMaxResults(10)
.setTimeMin(now)
.setOrderBy("startTime")
.setSingleEvents(true)
.execute();
List<Event> items = events.getItems();
for (Event event : items) {
String Location = event.getLocation(); // Getting location
// Toast.makeText(MainActivity.this, "Location " + Location, Toast.LENGTH_SHORT).show();
DateTime start = event.getStart().getDateTime();
if (start == null) {
// All-day events don't have start times, so just use
// All-day events don't have start times, so just use
// the start date.
start = event.getStart().getDate();
}
eventStrings.add(
String.format("%s (%s)", event.getSummary(), start));
}
return eventStrings;
}
@Override
protected void onPreExecute() {
mOutputText.setText("");
mProgress.show();
}
@Override
protected void onPostExecute(List<String> output) {
mProgress.hide();
if (output == null || output.size() == 0) {
mOutputText.setText("No results returned.");
} else {
output.add(0, "Data retrieved using the Google Calendar API:");
mOutputText.setText(TextUtils.join("\n", output));
}
}
@Override
protected void onCancelled() {
mProgress.hide();
if (mLastError != null) {
if (mLastError instanceof GooglePlayServicesAvailabilityIOException) {
showGooglePlayServicesAvailabilityErrorDialog(
((GooglePlayServicesAvailabilityIOException) mLastError)
.getConnectionStatusCode());
} else if (mLastError instanceof UserRecoverableAuthIOException) {
startActivityForResult(
((UserRecoverableAuthIOException) mLastError).getIntent(),
MainActivity.REQUEST_AUTHORIZATION);
} else {
mOutputText.setText("The following error occurred:\n"
+ mLastError.getMessage());
}
} else {
mOutputText.setText("Request cancelled.");
}
}
이것은 Google 캘린더에서 이벤트를 가져 오는 데 사용한 코드입니다. 일정에서 일정을 삭제할 수있는 방법이 있습니까? 예를 들어 주시면 감사하겠습니다. 참고 :
[일정에서 특정 이벤트를 삭제하는 방법] 가능한 복제본 (http://stackoverflow.com/questions/6924438/how-to-delete-specific-event-in-calendar) –
복제 방법은 무엇입니까? google 캘린더에 대해 묻는 오전 사전 설치된 모바일 캘린더 –
Google 캘린더에서 작동하지 않는 이유 [캘린더 제공 업체] (https://developer.android.com/guide/topics/providers/calendar-provider.html))? – Divers