I improve my app with jokes and I have problem. I would like to add "send by sms button
" and i would like to send text in TextView
through SMS
(If user choose joke and he will want send by SMS
).
How Can I do that?
I improve my app with jokes and I have problem. I would like to add "send by sms button
" and i would like to send text in TextView
through SMS
(If user choose joke and he will want send by SMS
).
How Can I do that?
<uses-permission android:name="android.permission.SEND_SMS"/>
sendMySmsBtn=(Button)findViewById(R.id.send);
sendMySmsBtn.setonclickListener(new OnClickListener(){
public void Onclick()
{
sendSMS("99999999999", "message");
});
private void sendSMS(String phoneNumber, String message)
{
SmsManager sms = SmsManager.getDefault();
sms.sendTextMessage(phoneNumber, null, message,null, null);
}
int phoneNumber=9999999999;
Intent startSmsApp=new Intent(Intent.ACTION_VIEW, Uri.parse("sms:"
+ phoneNumber);
startSmsApp.putExtra("sms_body", message);
startActivity(startSmsApp);
See Send SMS in android. It is not possible to send Texts automaticly, Android secured that function. This code will start an Intent to the SMS send applicataion:
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("sms:"
+ phoneNumber)));
Also see this tutorial and this tutorial.