Example usage for android.media AudioManager RINGER_MODE_VIBRATE

List of usage examples for android.media AudioManager RINGER_MODE_VIBRATE

Introduction

In this page you can find the example usage for android.media AudioManager RINGER_MODE_VIBRATE.

Prototype

int RINGER_MODE_VIBRATE

To view the source code for android.media AudioManager RINGER_MODE_VIBRATE.

Click Source Link

Document

Ringer mode that will be silent and will vibrate.

Usage

From source file:Main.java

public static void setVibrateOnly(AudioManager audiomanager) {
    audiomanager.setRingerMode(AudioManager.RINGER_MODE_VIBRATE);
    audiomanager.setVibrateSetting(AudioManager.VIBRATE_TYPE_RINGER, AudioManager.VIBRATE_SETTING_ON);
}

From source file:Main.java

public static boolean isSupportedMode(int ringerMode) {
    switch (ringerMode) {
    case AudioManager.RINGER_MODE_NORMAL:
    case AudioManager.RINGER_MODE_VIBRATE:
    case AudioManager.RINGER_MODE_SILENT:
        return true;
    }//from w  w w .ja v  a 2s.  c o m
    return false;
}

From source file:Main.java

public static final void audioModeVibrate(Context ctx) {
    AudioManager audio = (AudioManager) ctx.getSystemService(Context.AUDIO_SERVICE);
    audio.setRingerMode(AudioManager.RINGER_MODE_VIBRATE);
}

From source file:Main.java

public static void setRingerMode(Context mContext, int x) {
    AudioManager am = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
    switch (x) {//from w ww .  j a va  2s.  c  o m
    case 0:
        am.setRingerMode(AudioManager.RINGER_MODE_SILENT);
        break;
    case 1:
        am.setRingerMode(AudioManager.RINGER_MODE_VIBRATE);
        break;
    case 2:
        am.setRingerMode(AudioManager.RINGER_MODE_NORMAL);
        break;
    /*case 3:
       am.setRingerMode(AudioManager.RINGER_MODE_);
       break;*/
    }
}

From source file:Main.java

public static void setRingerModeBack(Context context) {
    if (currentMode == AudioManager.RINGER_MODE_NORMAL) {
        setRinger2Normal(context);// w w  w .j a  v a2  s. c o m
        Log.i("Restored Mode normal", currentVolume + "");
    } else if (currentMode == AudioManager.RINGER_MODE_VIBRATE) {
        setRinger2Vibrate(context);
        Log.i("Restored Mode vibrate", currentVolume + "");
    } else if (currentMode == AudioManager.RINGER_MODE_SILENT) {
        setRinger2Silent(context);
        Log.i("Restored Mode Silent", currentVolume + "");
    } else {
        Log.i("Nothing ", "Matched above");
    }
}

From source file:Main.java

public static void setCurrentRingerMode(Context context) {
    AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
    if (audioManager.getRingerMode() == AudioManager.RINGER_MODE_NORMAL) {
        currentMode = AudioManager.RINGER_MODE_NORMAL;
        currentVolume = audioManager.getStreamVolume(AudioManager.STREAM_RING);
        Log.i("Current Mode Normal", currentVolume + "");
        Log.i("Vlaue of", currentMode + "");
    } else if (audioManager.getRingerMode() == AudioManager.RINGER_MODE_VIBRATE) {
        currentMode = AudioManager.RINGER_MODE_VIBRATE;
        Log.i("Current Mode Vibrate", currentVolume + "");
        Log.i("Vlaue of", currentMode + "");
    } else if (audioManager.getRingerMode() == AudioManager.RINGER_MODE_SILENT) {
        currentMode = AudioManager.RINGER_MODE_SILENT;
        Log.i("Current Mode Silent", currentVolume + "");
        Log.i("Vlaue of", currentMode + "");
    } else {//from   w  w w. j a v a2s.  c om
        Log.i("Nothing ", "Matched above");
    }

}

From source file:Main.java

public static void setRinger2Vibrate(Context context) {
    AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
    audioManager.setRingerMode(AudioManager.RINGER_MODE_VIBRATE);
    Log.i("HelperFunctions ", "Vibrate method called");
}

From source file:com.metinkale.prayerapp.vakit.AlarmReceiver.java

public static void silenter(Context c, long dur) {
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(c);
    boolean silent = "silent".equals(prefs.getString("silenterType", "silent"));
    AudioManager aum = (AudioManager) c.getSystemService(Context.AUDIO_SERVICE);
    int ringermode = aum.getRingerMode();
    if ((ringermode != AudioManager.RINGER_MODE_SILENT)
            && ((ringermode != AudioManager.RINGER_MODE_VIBRATE) || silent)) {
        AlarmManager am = (AlarmManager) c.getSystemService(Context.ALARM_SERVICE);

        Intent i;/*  w  w w  .ja  v a 2s .c om*/
        if (ringermode == AudioManager.RINGER_MODE_VIBRATE) {
            i = new Intent(c, setVibrate.class);
        } else {
            i = new Intent(c, setNormal.class);
        }

        PendingIntent service = PendingIntent.getBroadcast(c, 0, i, PendingIntent.FLAG_UPDATE_CURRENT);

        am.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + (1000 * 60 * dur), service);

        if (PermissionUtils.get(c).pNotPolicy)
            aum.setRingerMode(silent ? AudioManager.RINGER_MODE_SILENT : AudioManager.RINGER_MODE_VIBRATE);

    }
}

From source file:com.intellisol.plugin.Ringer.java

@Override
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
    if (NATIVE_ACTION_STRING.equals(action)) {
        int mode;
        try {/*w w w. ja  v  a 2  s. co m*/
            // get mode from argument
            mode = args.getInt(0);

            // get context (Android)
            Context ctxt = cordova.getActivity().getBaseContext();
            if (mode == NORMAL) {
                // set ringer mode
                AudioManager audioManager = (AudioManager) ctxt.getSystemService(Context.AUDIO_SERVICE);
                audioManager.setRingerMode(AudioManager.RINGER_MODE_NORMAL);
            } else if (mode == VIBRATE) {
                AudioManager audioManager = (AudioManager) ctxt.getSystemService(Context.AUDIO_SERVICE);
                audioManager.setRingerMode(AudioManager.RINGER_MODE_VIBRATE);
            } else if (mode == SILENT) {
                AudioManager audioManager = (AudioManager) ctxt.getSystemService(Context.AUDIO_SERVICE);
                audioManager.setRingerMode(AudioManager.RINGER_MODE_SILENT);
            }

        } catch (JSONException e) {
            // log error
            Log.d("Ringer", e.toString());
            return false;
        } catch (Exception e) {
            // log error
            Log.d("Ringer", e.toString());
            return false;
        }
    }
    return true;
}

From source file:com.kyakujin.android.autoeco.ui.SilentModeSettingFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    mActivity = getActivity();/*w  w w .  j  a  v  a2s  .  co m*/
    LayoutInflater inflater = getActivity().getLayoutInflater();
    View view = inflater.inflate(R.layout.fragment_dialog_silentmode, null, false);
    RadioGroup radioGroup = (RadioGroup) view.findViewById(R.id.radioGroupSilentMode);

    // ?????????
    radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
        public void onCheckedChanged(RadioGroup group, int checkedId) {
            switch (checkedId) {
            case R.id.radioNormal:
                mSilentMode = AudioManager.RINGER_MODE_NORMAL;
                break;
            case R.id.radioSilent:
                mSilentMode = AudioManager.RINGER_MODE_SILENT;
                break;
            case R.id.radioVibrate:
                mSilentMode = AudioManager.RINGER_MODE_VIBRATE;
                break;
            default:
            }
        }
    });

    mCurrentEcoId = getArguments().getInt(Conf.SHARED_ECOID);
    mSilentMode = getArguments().getInt(Conf.SHARED_SILENTMODE);

    switch (mSilentMode) {
    case AudioManager.RINGER_MODE_NORMAL:
        radioGroup.check(R.id.radioNormal);
        break;
    case AudioManager.RINGER_MODE_SILENT:
        radioGroup.check(R.id.radioSilent);
        break;
    case AudioManager.RINGER_MODE_VIBRATE:
        radioGroup.check(R.id.radioVibrate);
        break;
    default:
    }

    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setTitle(R.string.setting_silent);
    builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            EcoDAO dao = new EcoDAO(mActivity);
            dao.updateSilentMode(mCurrentEcoId, mSilentMode);
        }
    });
    builder.setNegativeButton("Cancel", null);
    builder.setView(view);

    return builder.create();

}