android.provider.AlarmClock Java Examples
The following examples show how to use
android.provider.AlarmClock.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AlarmDialog.java From SuntimesWidget with GNU General Public License v3.0 | 7 votes |
public static void scheduleAlarm(Activity context, String label, Calendar calendar, SolarEvents event) { if (calendar == null) return; Calendar alarm = new GregorianCalendar(TimeZone.getDefault()); alarm.setTimeInMillis(calendar.getTimeInMillis()); int hour = alarm.get(Calendar.HOUR_OF_DAY); int minutes = alarm.get(Calendar.MINUTE); Intent alarmIntent = new Intent(AlarmClock.ACTION_SET_ALARM); alarmIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); //alarmIntent.putExtra(AlarmClock.EXTRA_MESSAGE, label); alarmIntent.putExtra(AlarmClock.EXTRA_HOUR, hour); alarmIntent.putExtra(AlarmClock.EXTRA_MINUTES, minutes); alarmIntent.putExtra(AlarmClockActivity.EXTRA_SOLAREVENT, event.name()); if (alarmIntent.resolveActivity(context.getPackageManager()) != null) { context.startActivity(alarmIntent); } }
Example #2
Source File: ClockActivity.java From TabletClock with MIT License | 6 votes |
@SuppressLint("InlinedApi") @Override public void onClick(View v) { if (android.os.Build.VERSION.SDK_INT >= 9) { if (v == mAlarm1View || v == mAlarm2View) { Animations.click(v, this); } else { try { Intent i = new Intent( android.os.Build.VERSION.SDK_INT >= 19 ? AlarmClock.ACTION_SHOW_ALARMS : AlarmClock.ACTION_SET_ALARM); startActivity(i); } catch (Exception e) { Toast.makeText(ClockActivity.this, R.string.alerror, Toast.LENGTH_SHORT).show(); } } } else { mWheatherFlipListener.onClick(v); } }
Example #3
Source File: MainActivity.java From Alarmio with Apache License 2.0 | 5 votes |
/** * Determine if something needs to be done as a result * of the intent being sent to the activity - which has * a higher priority than any fragment that is currently * open. * * @param intent The intent passed to the activity. * @return True if a fragment should be replaced * with the action that this intent entails. */ private boolean isActionableIntent(Intent intent) { return intent.hasExtra(EXTRA_FRAGMENT) || (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && (AlarmClock.ACTION_SHOW_ALARMS.equals(intent.getAction()) || AlarmClock.ACTION_SET_TIMER.equals(intent.getAction())) || AlarmClock.ACTION_SET_ALARM.equals(intent.getAction()) || (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && (AlarmClock.ACTION_SHOW_TIMERS.equals(intent.getAction())))); }
Example #4
Source File: AbstractRemoteViewsPresenter.java From GeometricWeather with GNU Lesser General Public License v3.0 | 5 votes |
public static PendingIntent getAlarmPendingIntent(Context context, int requestCode) { return PendingIntent.getActivity( context, requestCode, new Intent(AlarmClock.ACTION_SHOW_ALARMS), PendingIntent.FLAG_UPDATE_CURRENT); }
Example #5
Source File: AndroidSystemHandler.java From AlexaAndroid with GNU General Public License v2.0 | 5 votes |
private void setTimer(final AvsSetAlertItem item){ Intent i = new Intent(AlarmClock.ACTION_SET_TIMER); try { int time = (int) ((item.getScheduledTimeMillis() - System.currentTimeMillis()) / 1000); i.putExtra(AlarmClock.EXTRA_LENGTH, time); i.putExtra(AlarmClock.EXTRA_SKIP_UI, true); context.startActivity(i); AlexaManager.getInstance(context) .sendEvent(Event.getSetAlertSucceededEvent(item.getToken()), null); //cheating way to tell Alexa that the timer happened successfully--this SHOULD be improved //todo make this better new Handler(Looper.getMainLooper()).postDelayed(new Runnable() { @Override public void run() { AlexaManager.getInstance(context) .sendEvent(Event.getAlertStartedEvent(item.getToken()), new ImplAsyncCallback<AvsResponse, Exception>() { @Override public void complete() { AlexaManager.getInstance(context) .sendEvent(Event.getAlertStoppedEvent(item.getToken()), null); } }); } }, time * 1000); } catch (ParseException e) { e.printStackTrace(); } }
Example #6
Source File: AndroidSystemHandler.java From AlexaAndroid with GNU General Public License v2.0 | 5 votes |
private void setAlarm(AvsSetAlertItem item){ Intent i = new Intent(AlarmClock.ACTION_SET_ALARM); try { i.putExtra(AlarmClock.EXTRA_HOUR, item.getHour()); i.putExtra(AlarmClock.EXTRA_MINUTES, item.getMinutes()); i.putExtra(AlarmClock.EXTRA_SKIP_UI, true); context.startActivity(i); AlexaManager.getInstance(context) .sendEvent(Event.getSetAlertSucceededEvent(item.getToken()), null); } catch (ParseException e) { e.printStackTrace(); } }
Example #7
Source File: AlarmLoader.java From Easer with GNU General Public License v3.0 | 5 votes |
@Override public void _load(@ValidData @NonNull AlarmOperationData data, @NonNull OnResultCallback callback) { Intent intent = new Intent(AlarmClock.ACTION_SET_ALARM); int hour = data.time.get(Calendar.HOUR_OF_DAY); int minute = data.time.get(Calendar.MINUTE); if (!data.absolute) { Calendar calendar = Calendar.getInstance(); minute += calendar.get(Calendar.MINUTE); if (minute >= 60) { hour += 1; minute -= 60; } hour += calendar.get(Calendar.HOUR_OF_DAY); if (hour >= 24) { hour -= 24; } } intent.putExtra(AlarmClock.EXTRA_HOUR, hour); intent.putExtra(AlarmClock.EXTRA_MINUTES, minute); intent.putExtra(AlarmClock.EXTRA_MESSAGE, data.message); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { intent.putExtra(AlarmClock.EXTRA_VIBRATE, true); } intent.putExtra(AlarmClock.EXTRA_SKIP_UI, true); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); if (intent.resolveActivity(context.getPackageManager()) != null) { context.startActivity(intent); callback.onResult(true); } else callback.onResult(false); }
Example #8
Source File: VolumePanel.java From Noyze with Apache License 2.0 | 5 votes |
private void hookIntoEvents() { Context context = getContext(); MainThreadBus.get().register(this); mAppTypeMonitor = new AppTypeMonitor(MediaStore.ACTION_IMAGE_CAPTURE, AlarmClock.ACTION_SET_ALARM); mAppTypeMonitor.register(context); mPriorityModeObserver = new GlobalSetting(context, mUiHandler, Constants.ZEN_MODE) { @Override protected void handleValueChanged(int value) { mPriorityMode = value; onPriorityModeChanged(value); } }; mPriorityMode = mPriorityModeObserver.getValue(); mPriorityModeObserver.setListening(true); registeredOtto = true; }
Example #9
Source File: AlarmDialog.java From SuntimesWidget with GNU General Public License v3.0 | 5 votes |
/** * @param context a context used to start the "show alarm" intent */ @TargetApi(Build.VERSION_CODES.KITKAT) public static void showAlarms(Activity context) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { Intent alarmsIntent = new Intent(AlarmClock.ACTION_SHOW_ALARMS); alarmsIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); if (alarmsIntent.resolveActivity(context.getPackageManager()) != null) { context.startActivity(alarmsIntent); } } }
Example #10
Source File: IntentActivity.java From AndroidDemo with Apache License 2.0 | 5 votes |
public void createAlarm(View view) { Intent intent = new Intent(AlarmClock.ACTION_SET_ALARM) .putExtra(AlarmClock.EXTRA_MESSAGE, "createAlarm") .putExtra(AlarmClock.EXTRA_HOUR, 14) .putExtra(AlarmClock.EXTRA_MINUTES, 10); if (intent.resolveActivity(getPackageManager()) != null) { startActivity(intent); } }
Example #11
Source File: IntentActivity.java From AndroidDemo with Apache License 2.0 | 5 votes |
public void startTimer(View view) { Intent intent = new Intent(AlarmClock.ACTION_SET_TIMER) .putExtra(AlarmClock.EXTRA_MESSAGE, "Timer'") .putExtra(AlarmClock.EXTRA_LENGTH, 60) .putExtra(AlarmClock.EXTRA_SKIP_UI, true); if (intent.resolveActivity(getPackageManager()) != null) { startActivity(intent); } else { Toast.makeText(this, "No Activity", Toast.LENGTH_SHORT).show(); } }
Example #12
Source File: SetTimerActivity.java From android-Timer with Apache License 2.0 | 5 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); int paramLength = getIntent().getIntExtra(AlarmClock.EXTRA_LENGTH, 0); if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "SetTimerActivity:onCreate=" + paramLength); } if (paramLength > 0 && paramLength <= 86400) { long durationMillis = paramLength * 1000; setupTimer(durationMillis); finish(); return; } Resources res = getResources(); for (int i = 0; i < NUMBER_OF_TIMES; i++) { mTimeOptions[i] = new ListViewItem( res.getQuantityString(R.plurals.timer_minutes, i + 1, i + 1), (i + 1) * 60 * 1000); } setContentView(R.layout.timer_set_timer); // Initialize a simple list of countdown time options. mWearableListView = (WearableListView) findViewById(R.id.times_list_view); mWearableListView.setAdapter(new TimerWearableListViewAdapter(this)); mWearableListView.setClickListener(this); }
Example #13
Source File: VolumePanel.java From Noyze with Apache License 2.0 | 5 votes |
private void hookIntoEvents() { Context context = getContext(); MainThreadBus.get().register(this); mAppTypeMonitor = new AppTypeMonitor(MediaStore.ACTION_IMAGE_CAPTURE, AlarmClock.ACTION_SET_ALARM); mAppTypeMonitor.register(context); mPriorityModeObserver = new GlobalSetting(context, mUiHandler, Constants.ZEN_MODE) { @Override protected void handleValueChanged(int value) { mPriorityMode = value; onPriorityModeChanged(value); } }; mPriorityMode = mPriorityModeObserver.getValue(); mPriorityModeObserver.setListening(true); registeredOtto = true; }
Example #14
Source File: SetTimerActivity.java From AndroidWearable-Samples with Apache License 2.0 | 5 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); int paramLength = getIntent().getIntExtra(AlarmClock.EXTRA_LENGTH, 0); if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "SetTimerActivity:onCreate=" + paramLength); } if (paramLength > 0 && paramLength <= 86400) { long durationMillis = paramLength * 1000; setupTimer(durationMillis); finish(); return; } Resources res = getResources(); for (int i = 0; i < NUMBER_OF_TIMES; i++) { mTimeOptions[i] = new ListViewItem( res.getQuantityString(R.plurals.timer_minutes, i + 1, i + 1), (i + 1) * 60 * 1000); } setContentView(R.layout.timer_set_timer); // Initialize a simple list of countdown time options. mListView = (ListView) findViewById(R.id.times_list_view); ArrayAdapter<ListViewItem> arrayAdapter = new ArrayAdapter<ListViewItem>(this, android.R.layout.simple_list_item_1, mTimeOptions); mListView.setAdapter(arrayAdapter); mListView.setOnItemClickListener(this); mGoogleApiClient = new GoogleApiClient.Builder(this) .addApi(Wearable.API) .addConnectionCallbacks(this) .addOnConnectionFailedListener(this) .build(); }
Example #15
Source File: CalendarHelper.java From flow-android with MIT License | 5 votes |
public static Intent getAddAlarmIntent(String title, String location, Date startDate) { Calendar calendar = GregorianCalendar.getInstance(); calendar.setTime(startDate); Intent intent = new Intent(AlarmClock.ACTION_SET_ALARM); intent.putExtra(AlarmClock.EXTRA_HOUR, calendar.get(Calendar.HOUR_OF_DAY)); intent.putExtra(AlarmClock.EXTRA_MINUTES, calendar.get(Calendar.MINUTE)); intent.putExtra(AlarmClock.EXTRA_MESSAGE, String.format("%s - %s", title, location)); // To show the Alarm app after adding an alarm, uncomment the line below: // intent.putExtra(AlarmClock.EXTRA_SKIP_UI, true); /* Note: API 19 (KitKat) allows you to set the alarm's day(s) via the extra AlarmClock.EXTRA_DAYS */ return intent; }
Example #16
Source File: AlarmClockActivity.java From SuntimesWidget with GNU General Public License v3.0 | 4 votes |
protected void handleIntent(Intent intent) { String param_action = intent.getAction(); intent.setAction(null); Uri param_data = intent.getData(); intent.setData(null); boolean selectItem = true; if (param_action != null) { if (param_action.equals(AlarmClock.ACTION_SET_ALARM)) { String param_label = intent.getStringExtra(AlarmClock.EXTRA_MESSAGE); int param_hour = intent.getIntExtra(AlarmClock.EXTRA_HOUR, -1); int param_minute = intent.getIntExtra(AlarmClock.EXTRA_MINUTES, -1); ArrayList<Integer> param_days = AlarmRepeatDialog.PREF_DEF_ALARM_REPEATDAYS; boolean param_vibrate = AlarmSettings.loadPrefVibrateDefault(this); Uri param_ringtoneUri = AlarmSettings.getDefaultRingtoneUri(this, AlarmClockItem.AlarmType.ALARM); if (Build.VERSION.SDK_INT >= 19) { param_vibrate = intent.getBooleanExtra(AlarmClock.EXTRA_VIBRATE, param_vibrate); String param_ringtoneUriString = intent.getStringExtra(AlarmClock.EXTRA_RINGTONE); if (param_ringtoneUriString != null) { param_ringtoneUri = (param_ringtoneUriString.equals(AlarmClock.VALUE_RINGTONE_SILENT) ? null : Uri.parse(param_ringtoneUriString)); } ArrayList<Integer> repeatOnDays = intent.getIntegerArrayListExtra(AlarmClock.EXTRA_DAYS); if (repeatOnDays != null) { param_days = repeatOnDays; } } SolarEvents param_event = SolarEvents.valueOf(intent.getStringExtra(AlarmClockActivity.EXTRA_SOLAREVENT), null); //Log.i(TAG, "ACTION_SET_ALARM :: " + param_label + ", " + param_hour + ", " + param_minute + ", " + param_event); addAlarm(AlarmClockItem.AlarmType.ALARM, param_label, param_event, param_hour, param_minute, param_vibrate, param_ringtoneUri, param_days); } else if (param_action.equals(ACTION_ADD_ALARM)) { //Log.d(TAG, "handleIntent: add alarm"); showAddDialog(AlarmClockItem.AlarmType.ALARM); } else if (param_action.equals(ACTION_ADD_NOTIFICATION)) { //Log.d(TAG, "handleIntent: add notification"); showAddDialog(AlarmClockItem.AlarmType.NOTIFICATION); } else if (param_action.equals(AlarmNotifications.ACTION_DELETE)) { //Log.d(TAG, "handleIntent: alarm deleted"); if (adapter != null && alarmList != null) { if (param_data != null) { final AlarmClockItem item = adapter.findItem(ContentUris.parseId(param_data)); if (item != null) { adapter.onAlarmDeleted(true, item, alarmList.getChildAt(adapter.getPosition(item))); selectItem = false; } } else { onClearAlarms(true); selectItem = false; } } } } long selectedID = intent.getLongExtra(EXTRA_SELECTED_ALARM, -1); if (selectItem && selectedID != -1) { Log.d(TAG, "handleIntent: selected id: " + selectedID); t_selectedItem = selectedID; setSelectedItem(t_selectedItem); } }