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.
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);
}
}
Can someone help me how can I make this run?
Thanks in advance
Update
Here is my menifest file
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.zafar.silent"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="10" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".Silent"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<uses-permission android:name="android.permission.WRITE_SETTINGS"/>
<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS"/>
</application>
</manifest>
I updated menifest file