0

我設法從谷歌日曆中獲取數據,通過以下鏈接中的谷歌日曆API教程https://developers.google.com/google-apps/calendar/quickstart/android。如何編輯我從Android工作室中的谷歌日曆中獲取的數據?如何編輯我從Android工作室中的Google日曆中獲取的數據?

+0

你能請張貼到現在爲止您編寫的代碼? –

+0

我沒有更新中的任何代碼。 – ACE

+0

如果您想更新日曆中顯示的事件,請嘗試檢查[[Events:update']](https://developers.google.com/google-apps/calendar/v3/reference/events/更新)如果它可以幫助你。通過使用此功能,您可以更新或更改日曆中事件的元數據。查看此[示例](https://developers.google.com/google-apps/calendar/v3/reference/events/update#examples)關於如何使用JAVA更新日曆中的事件。 – KENdi

回答

0

這是我添加事件的代碼。

import android.content.Intent; 
import android.provider.CalendarContract; 
import android.support.v7.app.ActionBarActivity; 
import android.os.Bundle; 
import android.view.View; 
import java.util.Calendar; 
import android.provider.CalendarContract.Events; 

public class MainActivity extends ActionBarActivity { 

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_main); 
} 

public void onAddEventClicked(View view){ 
    Intent intent = new Intent(Intent.ACTION_INSERT); 
    intent.setType("vnd.android.cursor.item/event"); 

    Calendar cal = Calendar.getInstance(); 
    long startTime = cal.getTimeInMillis(); 
    long endTime = cal.getTimeInMillis() + 60 * 60 * 1000; 

    intent.putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, startTime); 
    intent.putExtra(CalendarContract.EXTRA_EVENT_END_TIME,endTime); 
    intent.putExtra(CalendarContract.EXTRA_EVENT_ALL_DAY, true); 

    intent.putExtra(Events.TITLE, "Create Event"); 
    intent.putExtra(Events.DESCRIPTION, "description"); 
    intent.putExtra(Events.EVENT_LOCATION, "My Guest House"); 
    intent.putExtra(Events.RRULE, "FREQ=YEARLY"); 

    startActivity(intent); 
} 

}

+0

你應該粘貼此代碼作爲問題的一部分,而不是答案 – KENdi