Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import android.content.Context;

import android.media.AudioManager;

import android.util.Log;

public class Main {
    static int currentVolume;
    static int currentMode;

    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 {
            Log.i("Nothing ", "Matched above");
        }

    }
}