Enable Full Silent Ringer mode without vibrate in android programmatically

How to turn on simple full silent ringer mode using android app on button click dynamically.

Simple full silent ringer mode means your android mobile phone device will be fully silent and dose not make any sound on notifications + incoming call. So here is the complete step by step tutorial for Enable Full Silent Ringer mode without vibrate in android programmatically.

android-project-download-code-button

How to Enable Full Silent Ringer mode without vibrate in android programmatically.

Code for MainActivity.java file.

 package com.enablesilentringermode_android_examples.com;
import android.app.Activity;
import android.content.Context;
import android.media.AudioManager;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class MainActivity extends Activity {
 Button button;
 AudioManager audiomanager;
 Context context;
 TextView textview;
 
 @Override
 protected void onCreate(Bundle savedInstanceState) {
 super.onCreate(savedInstanceState);
 setContentView(R.layout.activity_main);
 
 button = (Button)findViewById(R.id.button1);
 
 textview = (TextView)findViewById(R.id.textView1);
 
 context = getApplicationContext();
 
 audiomanager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
 
 button.setOnClickListener(new View.OnClickListener() {
 
 @Override
 public void onClick(View v) {
 // TODO Auto-generated method stub
 
 audiomanager.setRingerMode(AudioManager.RINGER_MODE_SILENT);
 
 textview.setText("Silent Mode Enable");
 
 }
 });
 }

}

Code for activity_main.xml layout file.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
 xmlns:tools="http://schemas.android.com/tools"
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 android:paddingBottom="@dimen/activity_vertical_margin"
 android:paddingLeft="@dimen/activity_horizontal_margin"
 android:paddingRight="@dimen/activity_horizontal_margin"
 android:paddingTop="@dimen/activity_vertical_margin"
 tools:context="com.enablesilentringermode_android_examples.com.MainActivity" >

 <Button
 android:id="@+id/button1"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:layout_centerHorizontal="true"
 android:layout_centerVertical="true"
 android:text="How to Enable Silent Ringer mode without vibrate in android programmatically" />
 
 <TextView
 android:id="@+id/textView1"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:layout_above="@+id/button1"
 android:layout_centerHorizontal="true"
 android:layout_marginBottom="44dp"
 android:text=""
 android:textAppearance="?android:attr/textAppearanceLarge" />

</RelativeLayout>

Screenshot:

Enable Full Silent Ringer mode without vibrate in android programmatically

Click here to download Enable Full Silent Ringer mode without vibrate in android programmatically project with source code.

Leave a Reply

Your email address will not be published. Required fields are marked *