Send SMS
@SuppressWarnings ("deprecation")
public void SendMessage (string Phoneno, String messagecontent)
{
Smsmanager Smsmanager = Smsmanager.getdefault ();
Smsmanager.sendtextmessage (phoneno,//receiver's mobile phone number
null,//Sender's mobile phone number
messagecontent,//Information Content
null,//whether a successful receipt is sent
null//receive a successful receipt
);
}
Play default ringtone
Private MediaPlayer MediaPlayer = new MediaPlayer ();
public Boolean ring ()
{
Uri Ringtoneuri = Ringtonemanager.getdefaulturi (Ringtonemanager.type_ringtone);
Try
{
Mediaplayer.setdatasource (this, Ringtoneuri);
Final Audiomanager Audiomanager = (audiomanager) getsystemservice (Context.audio_service);
if (Audiomanager.getstreamvolume (audiomanager.stream_voice_call)! = 0)
{
Mediaplayer.setaudiostreamtype (Audiomanager.stream_voice_call);
Mediaplayer.setlooping (FALSE);
Mediaplayer.prepare ();
Mediaplayer.start ();
return true;
}
}
catch (Exception e)
{
E.printstacktrace ();
}
return false;
}
Stop playing Ringtones
public void stopring ()
{
Mediaplayer.stop ();
}
Vibration
public void Vibrate (int ms)//input vibration milliseconds
{
Vibrator Vibrator = (Vibrator) getsystemservice (Vibrator_service);
Vibrator.vibrate (MS);
}
When using, be careful to add permissions in Androidmanifest.xml
Send SMS Permission
<uses-permission android:name= "Android.permission.SEND_SMS"/>
Vibration Permissions
<uses-permission android:name= "Android.permission.VIBRATE"/>
The implementation can be encapsulated in the service provided by the call, how to implement see Android service call, the parameters.
"Turn" Android phone send SMS, vibrate, play default ringtone