List of usage examples for android.media AudioManager RINGER_MODE_VIBRATE
int RINGER_MODE_VIBRATE
To view the source code for android.media AudioManager RINGER_MODE_VIBRATE.
Click Source Link
From source file:com.handmark.pulltorefresh.library.internal.LoadingLayout.java
public void refreshing() { if (hasPlayedSound) { hasPlayedSound = false;//from ww w . j a va 2s. c o m boolean isMuted = false; switch (audioManager.getRingerMode()) { case AudioManager.RINGER_MODE_NORMAL: isMuted = false; break; case AudioManager.RINGER_MODE_SILENT: isMuted = true; break; case AudioManager.RINGER_MODE_VIBRATE: isMuted = true; break; } if (mPreferences.getBoolean(PREFERENCE_KEY_SOUND_NAVIGATION, true)) { if (isMuted != true) { if (mPlayer != null) { if (mPlayer.isPlaying()) { mPlayer.stop(); } mPlayer.release(); } mPlayer = MediaPlayer.create(mContext, R.raw.release); mPlayer.start(); } } } mHeaderText.setText(Html.fromHtml(mRefreshingLabel)); mHeaderArrow.setVisibility(View.INVISIBLE); mHeaderProgress.setVisibility(View.VISIBLE); mSubHeaderText.setVisibility(View.GONE); }
From source file:com.kyakujin.android.autoeco.ui.EcoFragment.java
private void fillEco(Cursor c) { EcoDAO dao = new EcoDAO(mActivity); mModel = dao.readToEcoModelByCursor(c); // Description???? // Wifi Desc/*from www .java 2s . co m*/ if (mModel.getWifiEnabled()) { mWifiDesc.setText(getResources().getString(R.string.radio_on)); } else { mWifiDesc.setText(getResources().getString(R.string.radio_off)); } // Bluetooth Desc if (mModel.getBluetoothEnabled()) { mBluetoothDesc.setText(getResources().getString(R.string.radio_on)); } else { mBluetoothDesc.setText(getResources().getString(R.string.radio_off)); } // Rotate Desc if (mModel.getRotateEnabled()) { mRotateDesc.setText(getResources().getString(R.string.radio_on)); } else { mRotateDesc.setText(getResources().getString(R.string.radio_off)); } // Sync Desc if (mModel.getSyncEnabled()) { mSyncDesc.setText(getResources().getString(R.string.radio_on)); } else { mSyncDesc.setText(getResources().getString(R.string.radio_off)); } String desc = ""; // SilentMode Desc switch (mModel.getSilentMode()) { case AudioManager.RINGER_MODE_NORMAL: desc = getResources().getString(R.string.radio_normal); break; case AudioManager.RINGER_MODE_SILENT: desc = getResources().getString(R.string.radio_silent); break; case AudioManager.RINGER_MODE_VIBRATE: desc = getResources().getString(R.string.radio_vibrate); break; default: } mSilentDesc.setText(desc); // ? Desc if (mModel.getBrightnessAuto()) { desc = mActivity.getResources().getString(R.string.label_auto_brightness); } else { desc = String.valueOf(mModel.getBrightnessValue()); } mBrightnessDesc.setText(desc); // Sleep Desc mSleepTime = Conf.mapSleepTime.get(mModel.getSleepTimeOrdinal()); switch (mSleepTime) { case TIME1: mSleepTime = SleepTime.TIME1; mSleepDesc.setText(getResources().getString(R.string.radio_time1)); break; case TIME2: mSleepTime = SleepTime.TIME2; mSleepDesc.setText(getResources().getString(R.string.radio_time2)); break; case TIME3: mSleepTime = SleepTime.TIME3; mSleepDesc.setText(getResources().getString(R.string.radio_time3)); break; case TIME4: mSleepTime = SleepTime.TIME4; mSleepDesc.setText(getResources().getString(R.string.radio_time4)); break; case TIME5: mSleepTime = SleepTime.TIME5; mSleepDesc.setText(getResources().getString(R.string.radio_time5)); break; case TIME6: mSleepTime = SleepTime.TIME6; mSleepDesc.setText(getResources().getString(R.string.radio_time6)); break; default: } }
From source file:it.interfree.leonardoce.bootreceiver.AlarmKlaxon.java
private void startAlarm(MediaPlayer player) throws java.io.IOException, IllegalArgumentException, IllegalStateException { final AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); // Non deve suonare se il cellulare e' silenzioso Log.v(LTAG, "Stato del telefono: " + audioManager.getRingerMode()); // do not play alarms if stream volume is 0 // (typically because ringer mode is silent). if (audioManager.getStreamVolume(AudioManager.STREAM_ALARM) != 0 && audioManager.getRingerMode() != AudioManager.RINGER_MODE_SILENT && audioManager.getRingerMode() != AudioManager.RINGER_MODE_VIBRATE) { player.setAudioStreamType(AudioManager.STREAM_ALARM); player.setLooping(true);// w w w . ja v a 2 s. c om player.prepare(); player.start(); } }
From source file:com.handmark.pulltorefresh.library.internal.LoadingLayout.java
public void releaseToRefresh() { if (!mArrowRotated) { mHeaderArrow.startAnimation(mRotateAnimation); rotateArrow();// w w w .j a va 2 s .c o m mArrowRotated = true; if (!hasPlayedSound) { hasPlayedSound = true; boolean isMuted = false; switch (audioManager.getRingerMode()) { case AudioManager.RINGER_MODE_NORMAL: isMuted = false; break; case AudioManager.RINGER_MODE_SILENT: isMuted = true; break; case AudioManager.RINGER_MODE_VIBRATE: isMuted = true; break; } if (mPreferences.getBoolean(PREFERENCE_KEY_SOUND_NAVIGATION, true)) { if (isMuted != true) { if (mPlayer != null) { if (mPlayer.isPlaying()) { mPlayer.stop(); } mPlayer.release(); } mPlayer = MediaPlayer.create(mContext, R.raw.pulldown); mPlayer.start(); } } } } mHeaderText.setText(Html.fromHtml(mReleaseLabel)); }
From source file:cc.psdev.heywifi.MainService.java
private boolean changeRingmode() { for (int i = 0; i < 30; i++) { try {/*from www.ja v a 2s . co m*/ for (int j = 0; j < 20; j++) { if (ringmode[j] != -1 && resbssid[i].equals(bssid[j])) { if (pref.getSignal() == 1 && ressignal[i] < SIGNAL_MINIMUM) { continue; } else { if (pref.getRingmodeSaved() < 10) { switch (audm.getRingerMode()) { case 2: pref.putRingmodeSaved(12); break; case 1: pref.putRingmodeSaved(11); break; case 0: pref.putRingmodeSaved(10); break; } } switch (ringmode[j]) { case 2: audm.setRingerMode(AudioManager.RINGER_MODE_NORMAL); return true; case 1: audm.setRingerMode(AudioManager.RINGER_MODE_VIBRATE); return true; case 0: audm.setRingerMode(AudioManager.RINGER_MODE_SILENT); return true; } } } } } catch (NullPointerException ex) { } } return false; }
From source file:ch.carteggio.provider.sync.NotificationService.java
private void updateUnreadNotification(boolean newMessage) { NotificationManager mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); CarteggioProviderHelper helper = new CarteggioProviderHelper(this); int unreadCount = helper.getUnreadCount(); if (unreadCount == 0) { mNotificationManager.cancel(INCOMING_NOTIFICATION_ID); } else {//www.j a v a2 s. co m String quantityString = getResources().getQuantityString(R.plurals.notification_new_incoming_messages, unreadCount); NotificationCompat.Builder notifyBuilder = new NotificationCompat.Builder(this) .setContentTitle(String.format(quantityString, unreadCount)) .setSmallIcon(android.R.drawable.stat_notify_chat) .setContentText(getString(R.string.notification_text_new_messages)); Intent resultIntent = new Intent(this, MainActivity.class); TaskStackBuilder stackBuilder = TaskStackBuilder.create(this); stackBuilder.addParentStack(MainActivity.class); stackBuilder.addNextIntent(resultIntent); PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); notifyBuilder.setContentIntent(resultPendingIntent); if (newMessage) { Uri uri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); AudioManager manager = (AudioManager) getSystemService(AUDIO_SERVICE); long pattern[] = { 1000, 500, 2000 }; if (manager.getRingerMode() == AudioManager.RINGER_MODE_NORMAL) { notifyBuilder.setSound(uri); notifyBuilder.setVibrate(pattern); } else if (manager.getRingerMode() == AudioManager.RINGER_MODE_VIBRATE) { notifyBuilder.setVibrate(pattern); } } mNotificationManager.notify(INCOMING_NOTIFICATION_ID, notifyBuilder.build()); } }
From source file:org.sipdroid.sipua.ui.Receiver.java
public static void onState(int state, String caller) { if (ccCall == null) { ccCall = new Call(); ccConn = new Connection(); ccCall.setConn(ccConn);//from w ww . j a v a 2s . co m ccConn.setCall(ccCall); } if (call_state != state) { if (state != UserAgent.UA_STATE_IDLE) call_end_reason = -1; call_state = state; switch (call_state) { case UserAgent.UA_STATE_INCOMING_CALL: enable_wifi(true); RtpStreamReceiver.good = RtpStreamReceiver.lost = RtpStreamReceiver.loss = RtpStreamReceiver.late = 0; RtpStreamReceiver.speakermode = speakermode(); bluetooth = -1; String text = caller.toString(); if (text.indexOf("<sip:") >= 0 && text.indexOf("@") >= 0) text = text.substring(text.indexOf("<sip:") + 5, text.indexOf("@")); String text2 = caller.toString(); if (text2.indexOf("\"") >= 0) text2 = text2.substring(text2.indexOf("\"") + 1, text2.lastIndexOf("\"")); broadcastCallStateChanged("RINGING", caller); mContext.sendBroadcast(new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)); ccCall.setState(Call.State.INCOMING); ccConn.setUserData(null); ccConn.setAddress(text, text2); ccConn.setIncoming(true); ccConn.date = System.currentTimeMillis(); ccCall.base = 0; AudioManager am = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE); int rm = am.getRingerMode(); int vs = am.getVibrateSetting(AudioManager.VIBRATE_TYPE_RINGER); KeyguardManager mKeyguardManager = (KeyguardManager) mContext .getSystemService(Context.KEYGUARD_SERVICE); if (v == null) v = (Vibrator) mContext.getSystemService(Context.VIBRATOR_SERVICE); if ((pstn_state == null || pstn_state.equals("IDLE")) && PreferenceManager.getDefaultSharedPreferences(mContext).getBoolean( org.sipdroid.sipua.ui.Settings.PREF_AUTO_ON, org.sipdroid.sipua.ui.Settings.DEFAULT_AUTO_ON) && !mKeyguardManager.inKeyguardRestrictedInputMode()) v.vibrate(vibratePattern, 1); else { if ((pstn_state == null || pstn_state.equals("IDLE")) && (rm == AudioManager.RINGER_MODE_VIBRATE || (rm == AudioManager.RINGER_MODE_NORMAL && vs == AudioManager.VIBRATE_SETTING_ON))) v.vibrate(vibratePattern, 1); if (am.getStreamVolume(AudioManager.STREAM_RING) > 0) { String sUriSipRingtone = PreferenceManager.getDefaultSharedPreferences(mContext).getString( org.sipdroid.sipua.ui.Settings.PREF_SIPRINGTONE, Settings.System.DEFAULT_RINGTONE_URI.toString()); if (!TextUtils.isEmpty(sUriSipRingtone)) { oRingtone = RingtoneManager.getRingtone(mContext, Uri.parse(sUriSipRingtone)); if (oRingtone != null) oRingtone.play(); } } } moveTop(); if (wl == null) { PowerManager pm = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE); wl = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "Sipdroid.onState"); } wl.acquire(); Checkin.checkin(true); break; case UserAgent.UA_STATE_OUTGOING_CALL: RtpStreamReceiver.good = RtpStreamReceiver.lost = RtpStreamReceiver.loss = RtpStreamReceiver.late = 0; RtpStreamReceiver.speakermode = speakermode(); bluetooth = -1; onText(MISSED_CALL_NOTIFICATION, null, 0, 0); engine(mContext).register(); broadcastCallStateChanged("OFFHOOK", caller); ccCall.setState(Call.State.DIALING); ccConn.setUserData(null); ccConn.setAddress(caller, caller); ccConn.setIncoming(false); ccConn.date = System.currentTimeMillis(); ccCall.base = 0; moveTop(); Checkin.checkin(true); break; case UserAgent.UA_STATE_IDLE: broadcastCallStateChanged("IDLE", null); onText(CALL_NOTIFICATION, null, 0, 0); ccCall.setState(Call.State.DISCONNECTED); if (listener_video != null) listener_video.onHangup(); stopRingtone(); if (wl != null && wl.isHeld()) wl.release(); mContext.startActivity(createIntent(InCallScreen.class)); ccConn.log(ccCall.base); ccConn.date = 0; engine(mContext).listen(); break; case UserAgent.UA_STATE_INCALL: broadcastCallStateChanged("OFFHOOK", null); if (ccCall.base == 0) { ccCall.base = SystemClock.elapsedRealtime(); } progress(); ccCall.setState(Call.State.ACTIVE); stopRingtone(); if (wl != null && wl.isHeld()) wl.release(); mContext.startActivity(createIntent(InCallScreen.class)); break; case UserAgent.UA_STATE_HOLD: onText(CALL_NOTIFICATION, mContext.getString(R.string.card_title_on_hold), android.R.drawable.stat_sys_phone_call_on_hold, ccCall.base); ccCall.setState(Call.State.HOLDING); if (InCallScreen.started && (pstn_state == null || !pstn_state.equals("RINGING"))) mContext.startActivity(createIntent(InCallScreen.class)); break; } pos(true); RtpStreamReceiver.ringback(false); } }
From source file:net.geniecode.ttr.ScheduleReceiver.java
@SuppressWarnings("deprecation") @SuppressLint({ "Recycle", "NewApi", "InlinedApi" }) @Override/*from www. j ava2 s . c om*/ public void onReceive(Context context, Intent intent) { if (!Schedules.SCHEDULE_ACTION.equals(intent.getAction())) { // Unknown intent, bail. return; } Schedule schedule = null; // Grab the schedule from the intent. Since the remote AlarmManagerService // fills in the Intent to add some extra data, it must unparcel the // Schedule object. It throws a ClassNotFoundException when unparcelling. // To avoid this, do the marshalling ourselves. final byte[] data = intent.getByteArrayExtra(Schedules.SCHEDULE_RAW_DATA); if (data != null) { Parcel in = Parcel.obtain(); in.unmarshall(data, 0, data.length); in.setDataPosition(0); schedule = Schedule.CREATOR.createFromParcel(in); } if (schedule == null) { // Make sure we set the next schedule if needed. Schedules.setNextSchedule(context); return; } // Disable this schedule if it does not repeat. if (!schedule.daysOfWeek.isRepeatSet()) { Schedules.enableSchedule(context, schedule.id, false); } else { // Enable the next schedule if there is one. The above call to // enableSchedule will call setNextSchedule so avoid calling it twice. Schedules.setNextSchedule(context); } long now = System.currentTimeMillis(); if (now > schedule.time + STALE_WINDOW) { return; } // Get telephony service mTelephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); // Execute only for devices with versions of Android less than 4.2 if (android.os.Build.VERSION.SDK_INT < 17) { // Get flight mode state boolean isEnabled = Settings.System.getInt(context.getContentResolver(), Settings.System.AIRPLANE_MODE_ON, 0) == 1; // Get Wi-Fi service mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); if ((schedule.aponoff) && (!isEnabled) && (schedule.mode.equals("1")) && (mTelephonyManager.getCallState() == TelephonyManager.CALL_STATE_IDLE)) { // Enable flight mode Settings.System.putInt(context.getContentResolver(), Settings.System.AIRPLANE_MODE_ON, isEnabled ? 0 : 1); // Get Wi-Fi state and disable that one too, just in case // (On some devices it doesn't get disabled when the flight mode is // turned on, so we do it here) boolean isWifiEnabled = mWifiManager.isWifiEnabled(); SharedPreferences settings = context.getSharedPreferences(PREFS_NAME, 0); if (isWifiEnabled) { SharedPreferences.Editor editor = settings.edit(); editor.putBoolean(WIFI_STATE, isWifiEnabled); editor.commit(); mWifiManager.setWifiEnabled(false); } else { SharedPreferences.Editor editor = settings.edit(); editor.putBoolean(WIFI_STATE, isWifiEnabled); editor.commit(); } // Post an intent to reload Intent relintent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED); relintent.putExtra("state", !isEnabled); context.sendBroadcast(relintent); } else if ((!schedule.aponoff) && (isEnabled) && (schedule.mode.equals("1"))) { // Disable flight mode Settings.System.putInt(context.getContentResolver(), Settings.System.AIRPLANE_MODE_ON, isEnabled ? 0 : 1); // Restore previously remembered Wi-Fi state SharedPreferences settings = context.getSharedPreferences(PREFS_NAME, 0); Boolean WiFiState = settings.getBoolean(WIFI_STATE, true); if (WiFiState) { mWifiManager.setWifiEnabled(true); } // Post an intent to reload Intent relintent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED); relintent.putExtra("state", !isEnabled); context.sendBroadcast(relintent); } // Check whether there are ongoing phone calls, and if so // show notification instead of just enabling the flight mode else if ((schedule.aponoff) && (!isEnabled) && (schedule.mode.equals("1")) && (mTelephonyManager.getCallState() != TelephonyManager.CALL_STATE_IDLE)) { setNotification(context); } // Execute for devices with Android 4.2 or higher } else { // Get flight mode state String result = Settings.Global.getString(context.getContentResolver(), Settings.Global.AIRPLANE_MODE_ON); if ((schedule.aponoff) && (result.equals("0")) && (schedule.mode.equals("1")) && (mTelephonyManager.getCallState() == TelephonyManager.CALL_STATE_IDLE)) { // Keep the device awake while enabling flight mode Intent service = new Intent(context, ScheduleIntentService.class); startWakefulService(context, service); } else if ((!schedule.aponoff) && (result.equals("1")) && (schedule.mode.equals("1"))) { // Keep the device awake while enabling flight mode Intent service = new Intent(context, ScheduleIntentService.class); startWakefulService(context, service); } else if ((schedule.aponoff) && (result.equals("0")) && (schedule.mode.equals("1")) && (mTelephonyManager.getCallState() != TelephonyManager.CALL_STATE_IDLE)) { setNotification(context); } } // Get audio service mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); // Get current ringer mode and set silent or normal mode accordingly switch (mAudioManager.getRingerMode()) { case AudioManager.RINGER_MODE_SILENT: if ((!schedule.silentonoff) && (schedule.mode.equals("2"))) { mAudioManager.setRingerMode(AudioManager.RINGER_MODE_NORMAL); } break; case AudioManager.RINGER_MODE_NORMAL: if ((schedule.silentonoff) && (schedule.mode.equals("2"))) { mAudioManager.setRingerMode(AudioManager.RINGER_MODE_SILENT); } break; case AudioManager.RINGER_MODE_VIBRATE: // If the phone is set to vibrate let's make it completely silent if ((schedule.silentonoff) && (schedule.mode.equals("2"))) { mAudioManager.setRingerMode(AudioManager.RINGER_MODE_SILENT); } // or restore the regular sounds on it if that's scheduled else if ((!schedule.silentonoff) && (schedule.mode.equals("2"))) { mAudioManager.setRingerMode(AudioManager.RINGER_MODE_NORMAL); } break; } }
From source file:fr.inria.ucn.collectors.SysStateCollector.java
@SuppressWarnings("deprecation") private JSONObject getAudioState(Context c) throws JSONException { AudioManager am = (AudioManager) c.getSystemService(Context.AUDIO_SERVICE); JSONObject data = new JSONObject(); data.put("is_bluetooth_a2dp_on", am.isBluetoothA2dpOn()); data.put("is_microphone_mute", am.isMicrophoneMute()); data.put("is_music_active", am.isMusicActive()); data.put("is_speaker_phone_on", am.isSpeakerphoneOn()); data.put("is_wired_headset_on", am.isWiredHeadsetOn()); switch (am.getMode()) { case AudioManager.MODE_IN_CALL: data.put("mode", "in_call"); break;// ww w. ja v a 2 s .c o m case AudioManager.MODE_IN_COMMUNICATION: data.put("mode", "in_comm"); break; case AudioManager.MODE_NORMAL: data.put("mode", "normal"); break; case AudioManager.MODE_RINGTONE: data.put("mode", "ringtone"); break; case AudioManager.MODE_INVALID: default: data.put("mode", "invalid"); break; } switch (am.getRingerMode()) { case AudioManager.RINGER_MODE_VIBRATE: data.put("ringer_mode", "vibrate"); break; case AudioManager.RINGER_MODE_SILENT: data.put("ringer_mode", "silent"); break; case AudioManager.RINGER_MODE_NORMAL: data.put("ringer_mode", "normal"); break; default: data.put("ringer_mode", "invalid"); break; } return data; }
From source file:cc.psdev.heywifi.MainService.java
private void changeFromSavedRingmode(int ringmode) { switch (ringmode) { case 2://from ww w. j av a 2 s .c om audm.setRingerMode(AudioManager.RINGER_MODE_NORMAL); break; case 1: audm.setRingerMode(AudioManager.RINGER_MODE_VIBRATE); break; case 0: audm.setRingerMode(AudioManager.RINGER_MODE_SILENT); break; } }