Android message prompts (vibrations and prompts), android
Protected AudioManager; protected Vibrator vibrator; audioManager = (audioManager) getSystemService (Context. AUDIO_SERVICE); // this method is called by the Context vibrator = (Vibrator) getSystemService (Context. VIBRATOR_SERVICE); // same as above/*** vibrate and play tone */public void vibrateAndPlayTone (EMMessage message) {if (System. currentTimeMillis ()-lastNotifiyTime <1000) {// encoded ed new messages within 2 seconds, skip play ringtone return;} try {lastNotifiyTime = System. currentTimeMillis (); // check if in silent mode if (audioManager. getRingerMode () = AudioManager. RINGER_MODE_SILENT)
{
Log. e ("TAG", "mute"); return;} long [] pattern = new long [] {0,180, 80,120}; vibrator. vibrate (pattern,-1); // shake if (ringtone = null) {Uri icationicationuri = RingtoneManager. getDefaultUri (RingtoneManager. TYPE_NOTIFICATION); ringtone = RingtoneManager. getRingtone (appContext, icationicationuri); if (ringtone = null) {Log. d (TAG, "cant find ringtone at:" + icationicationuri. getPath (); return ;}
} If (! Ringtone. isPlaying () {// String vendor = Build. MANUFACTURER; ringtone. play (); // for samsung S3, we meet a bug that the phone will // continue ringtone without stop // so add below special handler to stop it after 3 s if // needed if (vendor! = Null & vendor. toLowerCase (). contains ("samsung") {Thread ctlThread = new Thread () {public void run () {try {Thread. sleep (1, 3000); if (ringtone. isPlaying () {ringtone. stop () ;}} catch (Exception e) {}}; ctlThread. run () ;}} catch (Exception e) {e. printStackTrace ();}}