本文整理汇总了Java中android.provider.AlarmClock.ACTION_SET_ALARM属性的典型用法代码示例。如果您正苦于以下问题:Java AlarmClock.ACTION_SET_ALARM属性的具体用法?Java AlarmClock.ACTION_SET_ALARM怎么用?Java AlarmClock.ACTION_SET_ALARM使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.provider.AlarmClock
的用法示例。
在下文中一共展示了AlarmClock.ACTION_SET_ALARM属性的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setAlarm
private void setAlarm(LocalDateTime alarmTime) {
Alarm alarm = new Alarm.Builder(this)
.setArrivalTime(DateUtils.formatTime(arrivalTime))
.setStationName(scheduleViewPager.getAdapter().getPageTitle(scheduleViewPager.getCurrentItem()).toString())
.setTriggerTime(alarmTime.toDate().getTime())
.build();
Intent alarmIntent = new Intent(AlarmClock.ACTION_SET_ALARM);
alarmIntent.putExtra(AlarmClock.EXTRA_MESSAGE, alarm.getStationName() + " arrival reminder.");
alarmIntent.putExtra(AlarmClock.EXTRA_HOUR, alarmTime.getHourOfDay());
alarmIntent.putExtra(AlarmClock.EXTRA_MINUTES, alarmTime.getMinuteOfHour());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
alarmIntent.putExtra(AlarmClock.EXTRA_VIBRATE, sharedPreferences.getBoolean(getString(R.string.pref_key_alarm_vibrate), true));
String ringtone = sharedPreferences.getString(getString(R.string.pref_key_alarm_ringtone), "");
if (TextUtils.isEmpty(ringtone)) {
alarmIntent.putExtra(AlarmClock.VALUE_RINGTONE_SILENT, true);
} else {
alarmIntent.putExtra(AlarmClock.EXTRA_RINGTONE, ringtone);
}
}
startActivity(Intent.createChooser(alarmIntent, "Set alarm"));
Snackbar.make(coordinatorLayout, "Alarm set for " + DateUtils.formatTime(alarmTime), Snackbar.LENGTH_LONG).show();
}
示例2: setAlarm
private void setAlarm(int hours,int minutes){
Intent i = new Intent(AlarmClock.ACTION_SET_ALARM);
i.putExtra(AlarmClock.EXTRA_MESSAGE, "It's about time!");
i.putExtra(AlarmClock.EXTRA_HOUR, hours);
i.putExtra(AlarmClock.EXTRA_MINUTES, minutes);
startActivity(i);
}
示例3: createOnClickPendingIntent
private PendingIntent createOnClickPendingIntent() {
Intent openClockIntent = new Intent(AlarmClock.ACTION_SET_ALARM);
ActivityInfo clockInfo = getPackageManager().resolveActivity(openClockIntent, 0).activityInfo;
return PendingIntent.getActivity(this, RC_OPEN_CLOCK,
getPackageManager().getLaunchIntentForPackage(clockInfo.packageName),
PendingIntent.FLAG_CANCEL_CURRENT);
}
示例4: setAlarm
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();
}
}
示例5: load
@Override
public boolean load(@ValidData @NonNull AlarmOperationData data) {
AlarmOperationData.AlarmData iData = data.data;
Intent intent = new Intent(AlarmClock.ACTION_SET_ALARM);
int hour = iData.time.get(Calendar.HOUR_OF_DAY);
int minute = iData.time.get(Calendar.MINUTE);
if (!iData.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, iData.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);
return true;
} else
return false;
}
示例6: hookIntoEvents
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;
}
示例7: setCoffeeReminder
@Override
public void setCoffeeReminder(MainActivity mainActivity, boolean isFirstCoffeeCycle) {
if (!canICoffeeView.getTimeWake().equals("")) {
Intent intent = new Intent(AlarmClock.ACTION_SET_ALARM);
// Log.i(TAG, "setCoffeeReminder isFirstCoffeeCycle: " + isFirstCoffeeCycle);
int hourOffset, minOffset;
String message;
if (isFirstCoffeeCycle) {
hourOffset = 3;
minOffset = 30;
message = mainActivity.getString(R.string.txt_remind_coffee_time_1);
} else {
hourOffset = 7;
minOffset = 30;
message = mainActivity.getString(R.string.txt_remind_coffee_time_2);
}
Time time = canICoffeeView.getTime();
Time coffeeTime = mTimeWorker.getTimeHourMin(time.getHour() + hourOffset, time.getMinutes() + minOffset);
Time fixedCoffeeTime = mTimeWorker.getFixedAmPm(coffeeTime.getHour(), coffeeTime.getMinutes());
int coffeeHour = (int) fixedCoffeeTime.getHour();
int coffeeMinute = (int) fixedCoffeeTime.getMinutes();
intent.putExtra(AlarmClock.EXTRA_HOUR, coffeeHour);
intent.putExtra(AlarmClock.EXTRA_MINUTES, coffeeMinute);
// Log.i(TAG, "setCoffeeReminder " + coffeeHour + "H" + coffeeMinute + "M");
intent.putExtra(AlarmClock.EXTRA_MESSAGE, message);
mainActivity.startActivity(intent);
} else {
Toast.makeText(mainActivity, mainActivity.getString(R.string.txt_toast_empty_time), Toast.LENGTH_SHORT).show();
}
}
示例8: onClick
@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);
}
}
示例9: onReceive
@Override
public void onReceive(final Context context, final Intent intent) {
if (intent.hasExtra(ALARM_ID)) {
GeoAlarm alarm = GeoAlarm.getGeoAlarm(context, UUID.fromString(intent.getStringExtra(ALARM_ID)));
if (alarm != null && alarm.enabled) {
ActiveAlarmManager activeAlarmManager = new ActiveAlarmManager(context);
Intent alarmClockIntent = new Intent(AlarmClock.ACTION_SET_ALARM);
Calendar cal = new GregorianCalendar();
alarmClockIntent.putExtra(AlarmClock.EXTRA_HOUR, cal.get(Calendar.HOUR_OF_DAY));
alarmClockIntent.putExtra(AlarmClock.EXTRA_MINUTES, cal.get(Calendar.MINUTE) + 1);
alarmClockIntent.putExtra(AlarmClock.EXTRA_SKIP_UI, true);
alarmClockIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
if (intent.resolveActivity(context.getPackageManager()) != null) {
context.startActivity(alarmClockIntent);
} else {
// TODO: I have no idea how to handle this
Log.e(TAG, "There is no alarm clock app");
}
if (alarm.days == null || alarm.days.isEmpty()) {
GeoAlarm.remove(context, alarm);
GeoAlarm.save(context, alarm.withEnabled(false));
activeAlarmManager.removeActiveAlarms(ImmutableSet.of(alarm.id));
} else {
activeAlarmManager.resetActiveAlarms();
}
}
}
}
示例10: getAddAlarmIntent
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;
}
示例11: setAlarm
private void setAlarm(Date date, int min) {
long time = date.getTime() - (long) 1000 * 60 * min;
Date newTime = new Date(time);
Intent openNewAlarm = new Intent(AlarmClock.ACTION_SET_ALARM);
openNewAlarm.putExtra(AlarmClock.EXTRA_HOUR, newTime.getHours());
openNewAlarm.putExtra(AlarmClock.EXTRA_MINUTES, newTime.getMinutes());
startActivity(openNewAlarm);
}
示例12: execute
@Override
public Message execute(String arguments, Command command, MAXSModuleIntentService service) {
String time;
String alarmDescription;
int spaceIndex = arguments.indexOf(' ');
if (spaceIndex == -1) {
time = arguments;
alarmDescription = null;
} else {
time = arguments.substring(0, spaceIndex);
alarmDescription = arguments.substring(spaceIndex);
}
String[] splitedTime = time.split(":");
if (splitedTime.length != 2) return new Message("Invalid time format: " + time, false);
int hour = Integer.parseInt(splitedTime[0]);
int minutes = Integer.parseInt(splitedTime[1]);
if (alarmDescription == null) alarmDescription = "Created by MAXS";
Intent intent = new Intent(AlarmClock.ACTION_SET_ALARM);
intent.putExtra(AlarmClock.EXTRA_MINUTES, minutes);
intent.putExtra(AlarmClock.EXTRA_HOUR, hour);
intent.putExtra(AlarmClock.EXTRA_MESSAGE, alarmDescription);
intent.putExtra(AlarmClock.EXTRA_SKIP_UI, true);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
service.startActivity(intent);
return new Message("Alarm set");
}
示例13: setupEditOnClick
private static void setupEditOnClick(Context context, RemoteViews widget) {
String intentAction = Build.VERSION.SDK_INT >= 19 ? AlarmClock.ACTION_SHOW_ALARMS : AlarmClock.ACTION_SET_ALARM;
Intent launchIntent = new Intent(intentAction);
PendingIntent launchPendingIntent = PendingIntent.getActivity(context, r.nextInt(), launchIntent, PendingIntent.FLAG_UPDATE_CURRENT);
widget.setOnClickPendingIntent(R.id.clock_edit_button, launchPendingIntent);
}
示例14: onOptionsItemSelected
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.mi_about_dq: {
WebView wv = new WebView(this);
String txt = getString(R.string.game_description);
wv.loadData(txt, "text/html", null);
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setView(wv).setTitle(R.string.mi_about_dq)
.setPositiveButton(null, null).setNegativeButton(null, null)
.setNeutralButton(null, null).show();
return true;
}
case R.id.mi_start_break: {
Intent i = new Intent(AlarmClock.ACTION_SET_ALARM);
Calendar rightNow = Calendar.getInstance();
ViewPager pager = (ViewPager) findViewById(R.id.pager);
int idx = pager.getCurrentItem();
int blen = shiftPrefs[idx].getInt(BREAKTIME,DEF_BREAKTIME);
rightNow.add(Calendar.MINUTE, prefs.getInt(BREAKTIME, blen));
i.putExtra(AlarmClock.EXTRA_MESSAGE, R.string.msg_back_to_work);
i.putExtra(AlarmClock.EXTRA_HOUR, rightNow.get(Calendar.HOUR_OF_DAY));
i.putExtra(AlarmClock.EXTRA_MINUTES, rightNow.get(Calendar.MINUTE));
i.putExtra(AlarmClock.EXTRA_SKIP_UI, true);
if (getPackageManager().queryIntentActivities(i, 0).size() == 0) {
Toast.makeText(this, R.string.msg_no_alarmclock, Toast.LENGTH_SHORT)
.show();
}
else {
startActivity(i);
}
return true;
}
case R.id.mi_share: {
Intent intent = new Intent("com.google.zxing.client.android.ENCODE");
intent.putExtra("ENCODE_TYPE","TEXT_TYPE");
intent.putExtra("ENCODE_DATA","market://details?id=de.onyxbits.drudgery");
startActivity(intent);
return true;
}
}
return super.onOptionsItemSelected(item);
}