当前位置: 首页>>代码示例>>Java>>正文


Java AudioManager.VIBRATE_SETTING_ON属性代码示例

本文整理汇总了Java中android.media.AudioManager.VIBRATE_SETTING_ON属性的典型用法代码示例。如果您正苦于以下问题:Java AudioManager.VIBRATE_SETTING_ON属性的具体用法?Java AudioManager.VIBRATE_SETTING_ON怎么用?Java AudioManager.VIBRATE_SETTING_ON使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在android.media.AudioManager的用法示例。


在下文中一共展示了AudioManager.VIBRATE_SETTING_ON属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: updateRingerMode

public void updateRingerMode() {

		AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
		synchronized (this) {
			int ringerMode = audioManager.getRingerMode();
			// Silent : stop everything
			if (ringerMode == AudioManager.RINGER_MODE_SILENT) {
				stopRing();
				return;
			}

			// Vibrate
			int vibrateSetting = audioManager.getVibrateSetting(AudioManager.VIBRATE_TYPE_RINGER);
			// If not already started restart it
			if (vibratorThread == null && (vibrateSetting == AudioManager.VIBRATE_SETTING_ON || ringerMode == AudioManager.RINGER_MODE_VIBRATE)) {
				vibratorThread = new VibratorThread();
				vibratorThread.start();
			}

			// Vibrate only
			if (ringerMode == AudioManager.RINGER_MODE_VIBRATE || audioManager.getStreamVolume(AudioManager.STREAM_RING) == 0) {
				stopRinger();
				return;
			}

            //Ringer
			ringerWorker.startRinging(audioManager);
		}
	}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:29,代码来源:Ringer.java

示例2: updateState

private void updateState() {
	
	final AudioManager manager = (AudioManager) mActivity.getSystemService(Context.AUDIO_SERVICE);
	if (manager == null) return;
	
	int ringer = manager.getRingerMode();
	int vibro = manager.getVibrateSetting(AudioManager.VIBRATE_TYPE_RINGER);
	
	int descr; int icon; boolean silent = false;
	if (ringer == AudioManager.RINGER_MODE_SILENT) {
		descr = R.string.txt_ringer_silent;
		icon = R.drawable.ic_silent;
		silent = true;
	} else if (ringer == AudioManager.RINGER_MODE_NORMAL) {
		if (vibro == AudioManager.VIBRATE_SETTING_ON) {
			descr = R.string.txt_ringer_vibrosound;
			icon = R.drawable.ic_vibro_sound;
		} else {
			descr = R.string.txt_ringer_sound;
			icon = R.drawable.ic_sound;
		}
	} else {
		descr = R.string.txt_ringer_vibro;
		icon = R.drawable.ic_vibro;
	}

	// update setting values
	Setting setting = mSetting;
	setting.descr = mActivity.getString(descr);
	setting.iconId = icon;
	setting.checked = !silent;
	setting.updateView();
	
}
 
开发者ID:sdrausty,项目名称:buildAPKsApps,代码行数:34,代码来源:RingerSettingHandler.java

示例3: onItemClick

public void onItemClick(AdapterView<?> arg0, View arg1, int index, long arg3) {
	
	AudioManager manager = (AudioManager) mActivity.getSystemService(Context.AUDIO_SERVICE);
	if (manager != null) {

		int ringerMode = AudioManager.RINGER_MODE_NORMAL;
		int vibroMode = AudioManager.VIBRATE_SETTING_ON;
		
		switch(index) {
			case 0: // silent
				ringerMode = AudioManager.RINGER_MODE_SILENT;
				vibroMode = AudioManager.VIBRATE_SETTING_ONLY_SILENT;
				break;
			case 1: // vibro
				ringerMode = AudioManager.RINGER_MODE_VIBRATE;
				vibroMode = AudioManager.VIBRATE_SETTING_ON;
				break;
			case 2: // sound
				ringerMode = AudioManager.RINGER_MODE_NORMAL;
				vibroMode = AudioManager.VIBRATE_SETTING_OFF;
				break;
			case 3: // sound and vibro
				ringerMode = AudioManager.RINGER_MODE_NORMAL;
				vibroMode = AudioManager.VIBRATE_SETTING_ON;
				break;
		}
		
		// update manager modes
		
		// update
		manager.setVibrateSetting(AudioManager.VIBRATE_TYPE_RINGER, vibroMode);
		manager.setVibrateSetting(AudioManager.VIBRATE_TYPE_NOTIFICATION, vibroMode);
		manager.setRingerMode(ringerMode);
		
		validateState(manager);
	}
	
	mDialog.hide();
}
 
开发者ID:sdrausty,项目名称:buildAPKsApps,代码行数:39,代码来源:RingerSettingHandler.java

示例4: ring

/**
 * Starts the ringtone and/or vibrator. 
 * 
 */
public void ring(String remoteContact, String defaultRingtone) {
    Log.d(THIS_FILE, "==> ring() called...");

    synchronized (this) {

    	AudioManager audioManager =
            (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
    	
    	//Save ringtone at the begining in case we raise vol
        Ringtone ringtone = getRingtone(remoteContact, defaultRingtone);
        ringerWorker.setRingtone(ringtone);
        
    	//No ring no vibrate
        int ringerMode = audioManager.getRingerMode();
        if (ringerMode == AudioManager.RINGER_MODE_SILENT) {
        	Log.d(THIS_FILE, "skipping ring and vibrate because profile is Silent");
        	return;
        }
        
        // Vibrate
        int vibrateSetting = audioManager.getVibrateSetting(AudioManager.VIBRATE_TYPE_RINGER);
        Log.d(THIS_FILE, "v=" + vibrateSetting + " rm=" + ringerMode);
        if (vibratorThread == null &&
        		(vibrateSetting == AudioManager.VIBRATE_SETTING_ON || 
        				ringerMode == AudioManager.RINGER_MODE_VIBRATE)) {
            vibratorThread = new VibratorThread();
            Log.d(THIS_FILE, "Starting vibrator...");
            vibratorThread.start();
        }

        // Vibrate only
        if (ringerMode == AudioManager.RINGER_MODE_VIBRATE ||
        		audioManager.getStreamVolume(AudioManager.STREAM_RING) == 0 ) {
        	Log.d(THIS_FILE, "skipping ring because profile is Vibrate OR because volume is zero");
        	return;
        }

        // Ringer normal, audio set for ring, do it
        if(ringtone == null) {
        	Log.d(THIS_FILE, "No ringtone available - do not ring");
        	return;
        }

        ringerWorker.startRinging(audioManager);
    	
    }
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:51,代码来源:Ringer.java


注:本文中的android.media.AudioManager.VIBRATE_SETTING_ON属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。