title: How to make android phone silent in java
body: <p>Hi I am new to android development. I am trying to make my android phone silent using java. After searching google I found some examples but they didnt workd for me. Here is my code.</p>
  
  <pre><code>package com.zafar.silent;
  
  import android.app.Activity;
  import android.content.Context;
  import android.media.AudioManager;
  import android.os.Bundle;
  
  public class Silent extends Activity {
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main);
      AudioManager audiomanage = (AudioManager)getSystemService(Context.AUDIO_SERVICE);
      audiomanage.setRingerMode(AudioManager.RINGER_MODE_SILENT);
  }
  }
  </code></pre>
  
  <p>Can someone help me how can I make this run?</p>
  
  <p>Thanks in advance</p>
  
  <p><strong>Update</strong></p>
  
  <p>Here is my menifest file</p>
  
  <pre><code>&lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.zafar.silent"
  android:versionCode="1"
  android:versionName="1.0" &gt;
  
  &lt;uses-sdk android:minSdkVersion="10" /&gt;
  
  &lt;application
      android:icon="@drawable/ic_launcher"
      android:label="@string/app_name" &gt;
      &lt;activity
          android:name=".Silent"
          android:label="@string/app_name" &gt;
          &lt;intent-filter&gt;
              &lt;action android:name="android.intent.action.MAIN" /&gt;
  
              &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
          &lt;/intent-filter&gt;
      &lt;/activity&gt;
      &lt;uses-permission android:name="android.permission.WRITE_SETTINGS"/&gt;
      &lt;uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS"/&gt;
  &lt;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>
  
  <p><strong>I updated menifest file</strong></p>