diff --git a/docs/html/guide/components/intents-common.jd b/docs/html/guide/components/intents-common.jd index f09ef9f1ea480..b81fc98684530 100644 --- a/docs/html/guide/components/intents-common.jd +++ b/docs/html/guide/components/intents-common.jd @@ -11,6 +11,18 @@ page.tags="IntentFilter" show less
To create a new alarm, use the {@link android.provider.AlarmClock#ACTION_SET_ALARM} +action and specify alarm details such as the time and message using extras defined below.
+ +Note: Only the hour, minutes, and message extras are available +since Android 2.3 (API level 9). The other extras were added in later versions of the platform.
+ +For a one-time alarm, do not specify this extra.
To use the default ringtone, do not specify this extra.
Example intent:
+
+public void createAlarm(String message, int hour, int minutes) {
+ Intent intent = new Intent(AlarmClock.ACTION_SET_ALARM)
+ .putExtra(AlarmClock.EXTRA_MESSAGE, message)
+ .putExtra(AlarmClock.EXTRA_HOUR, hour)
+ .putExtra(AlarmClock.EXTRA_MINUTES, minutes);
+ if (intent.resolveActivity(getPackageManager()) != null) {
+ startActivity(intent);
+ }
+}
+
+
+In order to invoke the {@link +android.provider.AlarmClock#ACTION_SET_ALARM} intent, your app must have the +{@link android.Manifest.permission#SET_ALARM} permission:
++<uses-permission android:name="com.android.alarm.permission.SET_ALARM" /> ++
Example intent filter:
++<activity ...> + <intent-filter> + <action android:name="android.intent.action.SET_ALARM" /> + <category android:name="android.intent.category.DEFAULT" /> + </intent-filter> +</activity> ++ + + +
To create a countdown timer, use the {@link android.provider.AlarmClock#ACTION_SET_TIMER} +action and specify timer details such as the duration using extras defined below.
+ +Note: This intent was added +in Android 4.4 (API level 19).
+ +Example intent:
+
+public void startTimer(String message, int seconds) {
+ Intent intent = new Intent(AlarmClock.ACTION_SET_TIMER)
+ .putExtra(AlarmClock.EXTRA_MESSAGE, message)
+ .putExtra(AlarmClock.EXTRA_LENGTH, seconds)
+ .putExtra(AlarmClock.EXTRA_SKIP_UI, true);
+ if (intent.resolveActivity(getPackageManager()) != null) {
+ startActivity(intent);
+ }
+}
+
+
+In order to invoke the {@link +android.provider.AlarmClock#ACTION_SET_TIMER} intent, your app must have the +{@link android.Manifest.permission#SET_ALARM} permission:
++<uses-permission android:name="com.android.alarm.permission.SET_ALARM" /> ++
Example intent filter:
++<activity ...> + <intent-filter> + <action android:name="android.intent.action.SET_TIMER" /> + <category android:name="android.intent.category.DEFAULT" /> + </intent-filter> +</activity> ++ + + + + +
To show the list of alarms, use the {@link android.provider.AlarmClock#ACTION_SHOW_ALARMS} +action.
+ +Although not many apps will invoke this intent (it's primarily used by system apps), +any app that behaves as an alarm clock should implement +this intent filter and respond by showing the list of current alarms.
+ +Note: This intent was added +in Android 4.4 (API level 19).
+ +Example intent filter:
++<activity ...> + <intent-filter> + <action android:name="android.intent.action.SHOW_ALARMS" /> + <category android:name="android.intent.category.DEFAULT" /> + </intent-filter> +</activity> ++ + + + + + +
To add a new event to the user's calendar, use the {@link android.content.Intent#ACTION_INSERT} +action and specify the data URI with {@link android.provider.CalendarContract.Events#CONTENT_URI +Events.CONTENT_URI}. You can then specify various event details using extras defined below.
+ +Many more event details can be specified using the constants defined in the + {@link android.provider.CalendarContract.EventsColumns} class.
+Example intent:
+
+public void addEvent(String title, String location, Calendar begin, Calendar end) {
+ Intent intent = new Intent(Intent.ACTION_INSERT)
+ .setData(Events.CONTENT_URI)
+ .putExtra(Events.TITLE, title)
+ .putExtra(Events.EVENT_LOCATION, location)
+ .putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, begin)
+ .putExtra(CalendarContract.EXTRA_EVENT_END_TIME, end);
+ if (intent.resolveActivity(getPackageManager()) != null) {
+ startActivity(intent);
+ }
+}
+
+
+
+Example intent filter:
++<activity ...> + <intent-filter> + <action android:name="android.intent.action.INSERT" /> + <data android:mimeType="vnd.android.cursor.dir/event" /> + <category android:name="android.intent.category.DEFAULT" /> + </intent-filter> +</activity> ++ + + + + + + + + + + + +
"data".
+
"subject"