List of usage examples for android.media RingtoneManager TYPE_ALARM
int TYPE_ALARM
To view the source code for android.media RingtoneManager TYPE_ALARM.
Click Source Link
From source file:org.cyanogenmod.theme.chooser.AudiblePreviewFragment.java
private void loadThemeAudible(Context themeCtx, int type, PackageInfo pi) { AssetManager assetManager = themeCtx.getAssets(); String assetPath;/*from w w w.j a v a 2 s. c o m*/ switch (type) { case RingtoneManager.TYPE_ALARM: assetPath = "alarms"; break; case RingtoneManager.TYPE_NOTIFICATION: assetPath = "notifications"; break; case RingtoneManager.TYPE_RINGTONE: assetPath = "ringtones"; break; default: assetPath = null; break; } if (assetPath != null) { try { String[] assetList = assetManager.list(assetPath); if (assetList != null && assetList.length > 0) { AssetFileDescriptor afd = assetManager.openFd(assetPath + File.separator + assetList[0]); MediaPlayer mp = initAudibleMediaPlayer(afd, type); if (mp != null) { addAudibleToLayout(type, mp); } } } catch (IOException e) { mMediaPlayers.put(type, null); } } }
From source file:com.aylanetworks.aura.GcmIntentService.java
private void sendNotification(String msg, String sound) { mNotificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE); // Find the launcher class for our application PackageManager pm = getPackageManager(); String packageName = getPackageName(); Intent query = new Intent(Intent.ACTION_MAIN); Class launcherClass = null;/*w w w . j a va 2 s.co m*/ query.addCategory(Intent.CATEGORY_LAUNCHER); List<ResolveInfo> foundIntents = pm.queryIntentActivities(query, 0); for (ResolveInfo info : foundIntents) { if (TextUtils.equals(info.activityInfo.packageName, packageName)) { launcherClass = info.activityInfo.getClass(); } } if (launcherClass == null) { Log.e(TAG, "Could not find application launcher class"); return; } Intent appIntent = new Intent(this, launcherClass); // main activity of Ayla Control/aMCA PendingIntent contentIntent = PendingIntent.getActivity(this, 0, appIntent, 0); //Determine the sound to be played Uri soundUri = null; if (sound == null) { // NOP //PushNotification.playSound("bdth.mp3"); } else if (sound.equals("none")) { // NOP } else if (sound.equals("default")) { soundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); // TYPE_NOTIFICATION or TYPE_ALARM } else if (sound.equals("alarm")) { soundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM); // TYPE_NOTIFICATION or TYPE_ALARM } else { boolean playedSound; playedSound = PushNotification.playSound(sound); if (playedSound == false) { soundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); // TYPE_NOTIFICATION or TYPE_ALARM } } // @formatter:off NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this) //.setSound(soundUri) .setSmallIcon(R.drawable.ic_push_icon).setContentTitle(getResources().getString(R.string.app_name)) .setStyle(new NotificationCompat.BigTextStyle().bigText(msg)).setLights(0xFFff0000, 500, 500) // flashing red light .setContentText(msg).setAutoCancel(true) //.setPriority(Notification.FLAG_HIGH_PRIORITY) .setDefaults(Notification.DEFAULT_VIBRATE | Notification.FLAG_SHOW_LIGHTS); // @formatter:on if (soundUri != null) { mBuilder.setSound(soundUri); } mBuilder.setPriority(PRIORITY_MAX); mBuilder.setContentIntent(contentIntent); mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build()); }
From source file:org.schabi.terminightor.AlarmItemDetailFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); lastSavedInstaneState = savedInstanceState; Activity a = getActivity();/*from ww w .j a v a 2s. c o m*/ setAlarmTimeView = (TextView) a.findViewById(R.id.setAlarmTimeView); setAlarmAMPMView = (TextView) a.findViewById(R.id.setAlarmAmPmSuffix); repeatCheckBox = (CheckBox) a.findViewById(R.id.setRepeatCheckBox); chooseDateView = (ChooseDaysView) a.findViewById(R.id.chooseDateView); alarmLabelBox = (EditText) a.findViewById(R.id.setAlarmLabelBox); setAlarmToneButton = (Button) a.findViewById(R.id.setAlarmToneButton); vibrateCheckBox = (CheckBox) a.findViewById(R.id.vibrateCheckBox); nfcTagLabelView = (ImageView) a.findViewById(R.id.nfcTagLabelView); nfcTagIdView = (TextView) a.findViewById(R.id.nfcTagIdView); addNfcTabButton = (FloatingActionButton) a.findViewById(R.id.addNfcTagButton); repeatCheckBox.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (repeatCheckBox.isChecked()) { chooseDateView.setVisibility(View.VISIBLE); } else { chooseDateView.setVisibility(View.GONE); } chooseDateView.setRepeatEnabled(repeatCheckBox.isChecked()); } }); setAlarmTimeView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { timePickerDialog.show(); } }); setAlarmToneButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER); intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TITLE, getResources().getString(R.string.selectAlarmToneTitle)); intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_SILENT, false); intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT, true); intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_ALARM); if (!alarm.getAlarmTone().isEmpty()) { intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, Uri.parse(alarm.getAlarmTone())); } startActivityForResult(intent, SET_ALARM_TONE); } }); addNfcTabButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(getActivity(), SetTagActivity.class); startActivityForResult(intent, READ_NFC_ID); } }); }
From source file:org.cyanogenmod.theme.chooser.AudiblePreviewFragment.java
private void addAudibleToLayout(int type, MediaPlayer mp) { View view = View.inflate(getActivity(), R.layout.audible_preview_item, null); TextView tv = (TextView) view.findViewById(R.id.audible_name); switch (type) { case RingtoneManager.TYPE_ALARM: tv.setText(R.string.alarm_label); break;/* w w w . ja va2 s. com*/ case RingtoneManager.TYPE_NOTIFICATION: tv.setText(R.string.notification_label); break; case RingtoneManager.TYPE_RINGTONE: tv.setText(R.string.ringtone_label); break; } ImageView iv = (ImageView) view.findViewById(R.id.btn_play_pause); iv.setTag(mp); iv.setOnClickListener(mPlayPauseClickListener); mContent.addView(view, ITEM_LAYOUT_PARAMS); }
From source file:saphion.batterycaster.providers.Alarm.java
public Alarm(int battery) { this.id = INVALID_ID; this.battery = battery; this.charge = 3; this.vibrate = true; this.daysOfWeek = new DaysOfWeek(0); this.label = ""; this.alert = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM); this.deleteAfterUse = false; }
From source file:com.brayanarias.alarmproject.activity.AlarmScreenActivity.java
private void playRingtone(String tone) { mediaPlayer = new MediaPlayer(); try {/* w w w .j av a 2 s . c om*/ Uri ringtoneUri; if (tone.equals("default")) { ringtoneUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM); } else { ringtoneUri = Uri.parse(tone); } if (ringtoneUri != null) { mediaPlayer.setDataSource(this, ringtoneUri); mediaPlayer.setAudioStreamType(AudioManager.STREAM_ALARM); mediaPlayer.setLooping(true); mediaPlayer.prepare(); AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); actualVolume = audioManager.getStreamVolume(AudioManager.STREAM_ALARM); incrementVolume(); mediaPlayer.start(); audioManager.setStreamVolume(AudioManager.STREAM_ALARM, 1, 0); } } catch (Exception e) { Log.e(tag, e.getLocalizedMessage(), e); } }
From source file:saphion.batterycaster.providers.Alarm.java
public Alarm(Cursor c) { id = c.getLong(ID_INDEX);/*from ww w. j a va 2 s. c o m*/ enabled = c.getInt(ENABLED_INDEX) == 1; battery = c.getInt(BATTERY_INDEX); charge = c.getInt(CHARGE_INDEX); daysOfWeek = new DaysOfWeek(c.getInt(DAYS_OF_WEEK_INDEX)); vibrate = c.getInt(VIBRATE_INDEX) == 1; label = c.getString(LABEL_INDEX); deleteAfterUse = c.getInt(DELETE_AFTER_USE_INDEX) == 1; if (c.isNull(RINGTONE_INDEX)) { // Should we be saving this with the current ringtone or leave it // null // so it changes when user changes default ringtone? alert = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM); } else { alert = Uri.parse(c.getString(RINGTONE_INDEX)); } }
From source file:com.geoffreybuttercrumbs.arewethereyet.DrawerFragment.java
protected void initTone() { Uri alert = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM); if (alert == null) { alert = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); if (alert == null) { alert = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE); }/* w w w.j a va2 s . co m*/ } uri = alert; }
From source file:com.geoffreybuttercrumbs.arewethereyet.DrawerFragment.java
protected void ringtonepicker() { Intent intent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER); intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_ALARM); intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TITLE, "Select Tone"); if (uri != null) { intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, uri); } else {/*from w w w . j ava2 s .c om*/ intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, (Uri) null); } startActivityForResult(intent, Set_Ringtone); SlidingFragmentActivity sfa = (SlidingFragmentActivity) getActivity(); sfa.showContent(); }
From source file:com.finchuk.clock2.alarms.ui.ExpandedAlarmViewHolder.java
private Uri getSelectedRingtoneUri() { // If showing an item for "Default" (@see EXTRA_RINGTONE_SHOW_DEFAULT), this can be one // of DEFAULT_RINGTONE_URI, DEFAULT_NOTIFICATION_URI, or DEFAULT_ALARM_ALERT_URI to have the // "Default" item checked. //// w w w. j a v a2 s .c om // Otherwise, use RingtoneManager.getActualDefaultRingtoneUri() to get the "actual sound URI". // // Do not use RingtoneManager.getDefaultUri(), because that just returns one of // DEFAULT_RINGTONE_URI, DEFAULT_NOTIFICATION_URI, or DEFAULT_ALARM_ALERT_URI // depending on the type requested (i.e. what the docs calls "symbolic URI // which will resolved to the actual sound when played"). String ringtone = getAlarm().ringtone(); return ringtone.isEmpty() ? RingtoneManager.getActualDefaultRingtoneUri(getContext(), RingtoneManager.TYPE_ALARM) : Uri.parse(ringtone); }