getRingerMode () always returns a value of 0
<p>I'm trying to determine the current ringer state by using the getRingerMode() method.</p>

<p><strong>I create a variable:</strong> private int currentRingerMode;</p>

<p><strong>Set my variable to:</strong> currentRingerMode = getRingerMode();</p>

<p><strong>And use a methods as follows:</strong><br>
private int getRingerMode() {
        // TODO Auto-generated method stub
        return currentRingerMode;
    }</p>

<p><strong>But when I log the value of the variable with:</strong>      Log.v(TAG, "value=" + currentRingerMode);</p>

<p>A value of 0 is always returned, regardless of the the ringer state...??? What am I doing wrong?</p>

<p>Thanks.</p>

<p>-Brian</p>

<hr>

<p>-Update
Here is my current full code.</p>

<pre><code>package com.DoNotDisturb.widget;
</code></pre>

<p>import com.DoNotDisturb.widget.R;</p>

<p>import android.app.PendingIntent;
import android.app.Service;
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProvider;
import android.content.Context;
import android.content.ContextWrapper;
import android.content.Intent;
import android.media.AudioManager;
import android.util.Log;
import android.widget.RemoteViews;
import android.widget.Toast;</p>

<p>public class DoNotDisturbWidget extends AppWidgetProvider {</p>

<pre><code>private static final String ACTION_WIDGET_RECEIVER = "ActionRecieverWidget";
private static final String TAG = null;
private int currentRingerMode;
private int ringerMode;
private RemoteViews views = new RemoteViews("com.DoNotDisturb.widget", R.layout.main);  

private AudioManager getSystemService(String audioService) {
    // TODO Auto-generated method stub

    return null;
    }


@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {

    Intent intent = new Intent(context, DoNotDisturbWidget.class);
    intent.setAction(ACTION_WIDGET_RECEIVER);


    PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, intent, 0);
    views.setOnClickPendingIntent(R.id.button_one, pendingIntent);

    appWidgetManager.updateAppWidget(appWidgetIds, views);

    AudioManager mAudioManager = (AudioManager) getSystemService(Service.AUDIO_SERVICE); 
    int ringerMode = mAudioManager.getRingerMode();
    Log.d(TAG, "ringerMode value=" + ringerMode);

    ContextWrapper mContext = null;
    AudioManager manager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
    currentRingerMode = manager.getRingerMode();
    Log.d(TAG, "ringerMode value=" + currentRingerMode);

}   



@Override
public void onReceive(Context context, Intent intent) {

    if (intent.getAction().equals(ACTION_WIDGET_RECEIVER)){

        Log.d(TAG, "ringerMode value=" + ringerMode);

        try {

            //Silent
            if(currentRingerMode == 2){
            Toast.makeText(context, "Silent", Toast.LENGTH_SHORT).show();
            ((AudioManager) context.getSystemService(Context.AUDIO_SERVICE)).setRingerMode(AudioManager.RINGER_MODE_SILENT);
            Log.v(TAG, "After ButtonPress value=" + currentRingerMode);


            }

            //Vibrate
                if(currentRingerMode == 1){
                Toast.makeText(context, "Normal", Toast.LENGTH_SHORT).show();
                ((AudioManager) context.getSystemService(Context.AUDIO_SERVICE)).setRingerMode(AudioManager.RINGER_MODE_NORMAL);
                Log.v(TAG, "After ButtonPress value=" + currentRingerMode); 


                }

            //Normal Mode
            if(currentRingerMode == 0){
                Toast.makeText(context, "Silent", Toast.LENGTH_SHORT).show();
                ((AudioManager) context.getSystemService(Context.AUDIO_SERVICE)).setRingerMode(AudioManager.RINGER_MODE_SILENT);
                Log.v(TAG, "After ButtonPress value=" + currentRingerMode); 

            }
        }

        finally{}

     }

    super.onReceive(context, intent);
}
</code></pre>

<p>}</p>
