Put phone in vibrate in android Code
<p>I am trying to activate vibrate in android but evrey time i press the button the app crash.....</p>

<pre><code>silet.setRingerMode(AudioManager.RINGER_MODE_VIBRATE)
</code></pre>

<p>also i did the import thing.
and declare :</p>

<pre><code>public AudioManager silent;
</code></pre>

<p>Logcat:</p>

<pre><code>07-13 22:06:17.956: E/AndroidRuntime(11925): FATAL EXCEPTION: main
07-13 22:06:17.956: E/AndroidRuntime(11925): java.lang.IllegalStateException: Could not execute method of the activity
07-13 22:06:17.956: E/AndroidRuntime(11925):    at android.view.View$1.onClick(View.java:2072)
07-13 22:06:17.956: E/AndroidRuntime(11925):    at android.view.View.performClick(View.java:2408)
07-13 22:06:17.956: E/AndroidRuntime(11925):    at android.view.View$PerformClick.run(View.java:8816)
07-13 22:06:17.956: E/AndroidRuntime(11925):    at android.os.Handler.handleCallback(Handler.java:587)
07-13 22:06:17.956: E/AndroidRuntime(11925):    at android.os.Handler.dispatchMessage(Handler.java:92)
07-13 22:06:17.956: E/AndroidRuntime(11925):    at android.os.Looper.loop(Looper.java:123)
07-13 22:06:17.956: E/AndroidRuntime(11925):    at android.app.ActivityThread.main(ActivityThread.java:4627)
07-13 22:06:17.956: E/AndroidRuntime(11925):    at java.lang.reflect.Method.invokeNative(Native Method)
07-13 22:06:17.956: E/AndroidRuntime(11925):    at java.lang.reflect.Method.invoke(Method.java:521)
07-13 22:06:17.956: E/AndroidRuntime(11925):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
07-13 22:06:17.956: E/AndroidRuntime(11925):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
07-13 22:06:17.956: E/AndroidRuntime(11925):    at dalvik.system.NativeStart.main(Native Method)
07-13 22:06:17.956: E/AndroidRuntime(11925): Caused by: java.lang.reflect.InvocationTargetException
07-13 22:06:17.956: E/AndroidRuntime(11925):    at com.android.hello.MainActivity.click(MainActivity.java:25)
07-13 22:06:17.956: E/AndroidRuntime(11925):    at java.lang.reflect.Method.invokeNative(Native Method)
07-13 22:06:17.956: E/AndroidRuntime(11925):    at java.lang.reflect.Method.invoke(Method.java:521)
07-13 22:06:17.956: E/AndroidRuntime(11925):    at android.view.View$1.onClick(View.java:2067)
07-13 22:06:17.956: E/AndroidRuntime(11925):    ... 11 more
07-13 22:06:17.956: E/AndroidRuntime(11925): Caused by: java.lang.NullPointerException
</code></pre>
