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


Java AudioManager.RINGER_MODE_SILENT属性代码示例

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


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

示例1: onReceive

@Override
public void onReceive(Context context, Intent intent) {
    String event = null;
    String type = null;

    switch(intent.getAction()){
        case Intent.ACTION_SCREEN_OFF:
            event = DeviceEvent.EVENT_SCREEN_OFF;
            type = DeviceEvent.TYPE_SCREEN;
            break;

        case Intent.ACTION_SCREEN_ON:
            event = DeviceEvent.EVENT_SCREEN_ON;
            type = DeviceEvent.TYPE_SCREEN;
            break;

        case Intent.ACTION_USER_PRESENT:
            event = DeviceEvent.EVENT_SCREEN_USER_PRESENT;
            type = DeviceEvent.TYPE_SCREEN;
            break;

        case Intent.ACTION_BOOT_COMPLETED:
            event = DeviceEvent.EVENT_BOOT_COMPLETED;
            type = DeviceEvent.TYPE_BOOT;
            break;

        case Intent.ACTION_SHUTDOWN:
            event = DeviceEvent.EVENT_BOOT_SHUTDOWN;
            type = DeviceEvent.TYPE_BOOT;
            break;

        case Intent.ACTION_BATTERY_LOW:
            event = DeviceEvent.EVENT_BATTERY_LOW;
            type = DeviceEvent.TYPE_BATTERY;
            break;

        case Intent.ACTION_BATTERY_OKAY:
            event = DeviceEvent.EVENT_BATTERY_OKAY;
            type = DeviceEvent.TYPE_BATTERY;
            break;

        case Intent.ACTION_POWER_CONNECTED:
            event = DeviceEvent.EVENT_BATTERY_AC_CONNECTED;
            type = DeviceEvent.TYPE_BATTERY;
            break;

        case Intent.ACTION_POWER_DISCONNECTED:
            event = DeviceEvent.EVENT_BATTERY_AC_DISCONNECTED;
            type = DeviceEvent.TYPE_BATTERY;
            break;

        case AudioManager.RINGER_MODE_CHANGED_ACTION:
            AudioManager am = (AudioManager)getContext().getSystemService(Context.AUDIO_SERVICE);
            switch (am.getRingerMode()) {
                case AudioManager.RINGER_MODE_SILENT:
                    event = DeviceEvent.EVENT_RINGER_SILENT;
                    type = DeviceEvent.TYPE_RINGER;
                    break;

                case AudioManager.RINGER_MODE_VIBRATE:
                    event = DeviceEvent.EVENT_RINGER_VIBRATE;
                    type = DeviceEvent.TYPE_RINGER;
                    break;

                case AudioManager.RINGER_MODE_NORMAL:
                    event = DeviceEvent.EVENT_RINGER_NORMAL;
                    type = DeviceEvent.TYPE_RINGER;
                    break;
            }
        default:
            break;
    }

    if (type != null)
        output(new DeviceEvent(type, event));
}
 
开发者ID:PrivacyStreams,项目名称:PrivacyStreams,代码行数:76,代码来源:DeviceEventUpdatesProvider.java

示例2: shouldVibrateNew

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private boolean shouldVibrateNew(Context context, int ringerMode) {
    Vibrator vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);

    if (vibrator == null || !vibrator.hasVibrator()) {
        return false;
    }

    boolean vibrateWhenRinging = Settings.System.getInt(context.getContentResolver(), "vibrate_when_ringing", 0) != 0;

    if (vibrateWhenRinging) {
        return ringerMode != AudioManager.RINGER_MODE_SILENT;
    } else {
        return ringerMode == AudioManager.RINGER_MODE_VIBRATE;
    }
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:16,代码来源:IncomingRinger.java

示例3: shouldVibrateNew

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private boolean shouldVibrateNew(Context context, int ringerMode) {
  Vibrator vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);

  if (vibrator == null || !vibrator.hasVibrator()) {
    return false;
  }

  boolean vibrateWhenRinging = Settings.System.getInt(context.getContentResolver(), "vibrate_when_ringing", 0) != 0;

  if (vibrateWhenRinging) {
    return ringerMode != AudioManager.RINGER_MODE_SILENT;
  } else {
    return ringerMode == AudioManager.RINGER_MODE_VIBRATE;
  }
}
 
开发者ID:CableIM,项目名称:Cable-Android,代码行数:16,代码来源:IncomingRinger.java

示例4: buildUpdate

private RemoteViews buildUpdate(Context context) {
	RemoteViews updateViews = new RemoteViews(context.getPackageName(), R.layout.widget);

	AudioManager audioManager = (AudioManager) context.getSystemService(Activity.AUDIO_SERVICE);
	if (audioManager.getRingerMode() == AudioManager.RINGER_MODE_SILENT) {
		updateViews.setImageViewResource(R.id.phoneState, R.drawable.phone_state_normal);
		audioManager.setRingerMode(AudioManager.RINGER_MODE_NORMAL);
	} else {
		updateViews.setImageViewResource(R.id.phoneState, R.drawable.phone_state_silent);
		audioManager.setRingerMode(AudioManager.RINGER_MODE_SILENT);
	}

	Intent i = new Intent(this, AppWidget.class);
	PendingIntent pi = PendingIntent.getBroadcast(context, 0, i, 0);
	updateViews.setOnClickPendingIntent(R.id.phoneState, pi);

	return updateViews;

}
 
开发者ID:sdrausty,项目名称:buildAPKsApps,代码行数:19,代码来源:AppWidget.java

示例5: vibrate

/**
 * Vibrates the device for a given amount of time.
 *
 * @param time      Time to vibrate in ms.
 */
public void vibrate(long time) {
    // Start the vibration, 0 defaults to half a second.
    if (time == 0) {
        time = 500;
    }
    AudioManager manager = (AudioManager) this.cordova.getActivity().getSystemService(Context.AUDIO_SERVICE);
    if (manager.getRingerMode() != AudioManager.RINGER_MODE_SILENT) {
        Vibrator vibrator = (Vibrator) this.cordova.getActivity().getSystemService(Context.VIBRATOR_SERVICE);
        vibrator.vibrate(time);
    }
}
 
开发者ID:disit,项目名称:siiMobilityAppKit,代码行数:16,代码来源:Vibration.java

示例6: disableSoundAndVibration

private void disableSoundAndVibration() {
    AudioManager audioManager = (AudioManager) getActivity().getApplicationContext()
            .getSystemService(Context.AUDIO_SERVICE);
    mPreviousRingerMode = audioManager.getRingerMode();
    if(mPreviousRingerMode != AudioManager.RINGER_MODE_SILENT){
        Log.d(TAG, "Disabling sound and vibration");
        ringerModeChanged = true;
        audioManager.setRingerMode(AudioManager.RINGER_MODE_SILENT);
    }
}
 
开发者ID:swapyx,项目名称:Channelize,代码行数:10,代码来源:TimerFragment.java

示例7: vibrateShort

public void vibrateShort() {
	if (v == null)
		return;
	if (!buttonVibrationEnabled)
		return;
	if(((AudioManager)host.getSystemService(Context.AUDIO_SERVICE)).getRingerMode() == AudioManager.RINGER_MODE_SILENT)
		return;
	if((host.game.getTime() - shortVibeTime) > (host.getResources().getInteger(R.integer.shortVibeInterval) + vibrationOffset)) {
		shortVibeTime = host.game.getTime();
		v.vibrate(vibrationOffset);
	}
}
 
开发者ID:StringMon,项目名称:homescreenarcade,代码行数:12,代码来源:Controls.java

示例8: isMuted

/**
 * Checks if device is muted.
 */
static String isMuted(Context context) {
    AudioManager audio = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
    switch( audio.getRingerMode() ){
        case AudioManager.RINGER_MODE_SILENT:
            return "true";
        case AudioManager.RINGER_MODE_VIBRATE:
            return "true";
        default:
            return "false";
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:14,代码来源:CrashDetails.java

示例9: initAudioManager

private void initAudioManager() {
    mAudioManager = (AudioManager) mAppContext.getSystemService(Context.AUDIO_SERVICE);

    int mode = mAudioManager.getRingerMode();
    if (mode == AudioManager.RINGER_MODE_VIBRATE
            || mode == AudioManager.RINGER_MODE_SILENT) {
        // Normal mode will be audible and may vibrate according to user settings.
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
            NotificationManager n  = (NotificationManager) mAppContext.getSystemService(Context.NOTIFICATION_SERVICE);
            boolean isPolicyGranted = n != null && n.isNotificationPolicyAccessGranted();
            // fixme 7.0手机 如果没有这个权限 直接调用setRingerMode会报出 Not allowed to change Do Not Disturb state的异常.
            if (isPolicyGranted) {
                mAudioManager.setRingerMode(AudioManager.RINGER_MODE_NORMAL);
            }
        } else {
            mAudioManager.setRingerMode(AudioManager.RINGER_MODE_NORMAL);
        }
    }
    mAudioMaxVolume = mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
    int audioCurrentVolume = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
    if (mAudioMaxVolume != 0) {
        mCurrentVolume = (int) (((float) audioCurrentVolume / (float) mAudioMaxVolume) * 100);
    }
    PlayerLog.d(TAG, "initAudioManager mCurrentVolume is " + mCurrentVolume +
            " , mAudioMaxVolume is " + mAudioMaxVolume +
            " , audioCurrentVolume is " + audioCurrentVolume);
}
 
开发者ID:xinpianchang,项目名称:NSMPlayer-Android,代码行数:27,代码来源:VMoviePlayer.java

示例10: 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

示例11: onMessageReceived

@Override
public void onMessageReceived(MessageEvent messageEvent) {
    if (messageEvent.getPath().equalsIgnoreCase(DND_SYNC_PREFIX)) {
        // Read the received ringer or dnd mode and convert it back to an integer
        int newMode = Integer.parseInt(new String(messageEvent.getData()));

        if (SEND_RINGER_MODE) {
            Log.d(TAG, "Received new ringer mode " + newMode + " from source " + messageEvent.getSourceNodeId());
        } else {
            Log.d(TAG, "Received new dnd mode " + newMode + " from source " + messageEvent.getSourceNodeId());
        }

        NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

        // Check if the notification policy access has been granted for the app
        // This is needed to set modes that affect Do Not Disturb in Android N
        if (mNotificationManager.isNotificationPolicyAccessGranted()) {
            if (SEND_RINGER_MODE) {
                Log.d(TAG, "Attempting to set ringer mode " + newMode);

                AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);

                if (newMode == AudioManager.RINGER_MODE_SILENT) {
                    audioManager.setRingerMode(newMode);
                } else {
                    // Set the saved "normal" value
                    audioManager.setRingerMode(getNormalRingerMode());
                }
            } else {
                Log.d(TAG, "Attempting to set dnd mode " + newMode);

                mNotificationManager.setInterruptionFilter(newMode);
            }
        } else {
            Log.d(TAG, "App is not allowed to change Do Not Disturb mode without applying workaround");
        }
    } else {
        super.onMessageReceived(messageEvent);
    }
}
 
开发者ID:blunden,项目名称:DoNotDisturbSync,代码行数:40,代码来源:WearMessageListenerService.java

示例12: changeMobileToSilentMood

/**
 * Function to check to make mobile silent in prayer
 */
private void changeMobileToSilentMood() {
    AudioManager mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
    int ringerMode = mAudioManager.getRingerMode();
    if (ringerMode != AudioManager.RINGER_MODE_SILENT) {
        Alarms.switchToSilent(10, this);
    }
}
 
开发者ID:fekracomputers,项目名称:MuslimMateAndroid,代码行数:10,代码来源:PrayerNotification.java

示例13: 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

示例14: wasRingerModeVibrate

private boolean wasRingerModeVibrate() {
    return mVibrator != null && mRingerMode == AudioManager.RINGER_MODE_SILENT
            && mAudioManager.getLastAudibleStreamVolume(AudioManager.STREAM_RING) == 0;
}
 
开发者ID:ric96,项目名称:lineagex86,代码行数:4,代码来源:SoundSettings.java

示例15: onMessageReceived

@Override
public void onMessageReceived(MessageEvent messageEvent) {
    Log.d(TAG, "onMessageReceived: " + messageEvent);

    switch (messageEvent.getPath()) {
        case PATH_DND:
            if (messageEvent.getData().length == 0)
                return;

            int state = (int) messageEvent.getData()[0];

            Log.d(TAG, "Target state: " + state);

            if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
                NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
                if (state != NotificationManager.INTERRUPTION_FILTER_ALL)
                    state = NotificationManager.INTERRUPTION_FILTER_ALARMS;
                if (state == (int) notificationManager.getCurrentInterruptionFilter())
                    return;

                if (notificationManager.isNotificationPolicyAccessGranted())
                    notificationManager.setInterruptionFilter(state);
            } else if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                Intent intent = new Intent(LGHackService.ACTION_SET_STATE);
                intent.putExtra(LGHackService.EXTRA_STATE, (int) messageEvent.getData()[0]);
                sendBroadcast(intent);
            } else {
                AudioManager audioManager = (AudioManager) this.getSystemService(Context.AUDIO_SERVICE);
                state = state == 4 ?  AudioManager.RINGER_MODE_SILENT : AudioManager.RINGER_MODE_NORMAL;
                //INTERRUPTION_FILTER_ALARMS
                if (state == audioManager.getRingerMode())
                    return;
                audioManager.setRingerMode(state);
            }
            return;
        case PATH_DND_REGISTER:
            if (messageEvent.getData().length == 0)
                return;

            Intent connectIntent = new Intent(WEAR_CALLBACK_CONNECT);
            if (messageEvent.getData().length > 1) {
                DataMap config = DataMap.fromByteArray(messageEvent.getData());
                connectIntent.putExtra("permission", config.getBoolean("permission"));
            }
            sendBroadcast(connectIntent);
            Log.d(TAG, "Connected broadcast");
            return;
        case PATH_LOGS:
            if (messageEvent.getData().length == 0)
                return;

            Intent logIntent = new Intent(WEAR_CALLBACK_LOGS);
            logIntent.putExtra("log", new String(messageEvent.getData()));
            sendBroadcast(logIntent);
            Log.d(TAG, "Logs broadcast");
            return;
    }
}
 
开发者ID:rkkr,项目名称:wear-dnd-sync,代码行数:58,代码来源:SettingsService.java


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