Android send SMS automatically on button click

后端 未结 5 1620
孤独总比滥情好
孤独总比滥情好 2020-12-24 04:01

I am trying to automatically send SMS message to a certain number when the user presses a button on the screen.

This is my code:

Intent smsIntent = n         


        
5条回答
  •  有刺的猬
    2020-12-24 04:49

    Try this code:

     String messageToSend = "this is a message";
     String number = "2121234567";
    
     SmsManager.getDefault().sendTextMessage(number, null, messageToSend, null,null);
    

    With regards to the number, you need to enter the number as if you were calling it from the phone or sending an sms message in the normal manner.

提交回复
热议问题