Joke Collection Website - Public benefit messages - How to add the function of sending free SMS to Android system?
How to add the function of sending free SMS to Android system?
& ltuses-permission Android:name = " Android . permission . send _ SMS "/& gt;
Includes two TextView components, two EditText components and a Button component, and adds a click event on the send button in the main program.
Private EditText txt _ num
Private EditText txt _ content
public void on create(Bundle saved instancestate){
super . oncreate(savedInstanceState);
setContentView(r . layout . main);
txt _ num =(EditText)this . findviewbyid(r . id . txt _ num);
txt _ content =(EditText)this . findviewbyid(r . id . txt _ content);
Button BTN _ send =(Button)this . findviewbyid(r . id . BTN _ send);
BTN _ send . setonclicklistener(new OnClickListener(){
Public void onClick (view v)
String str_num = txt_num.getText()。 toString(); //Get the phone number
string str _ content = txt _ content . gettext()。 toString(); //Get the short message content
SMS manager manager _ SMS = SMS manager . get default(); //Get the SMS Manager.
//Because the message may be longer, split the message.
ArrayList & lt string & gt texts = SMS manager. Divide message (str _ content);
For (string text: text) (
SMS manager . sendtextmessage(str _ num,null,text,null,null); //Send each message separately.
}
Toast. Maketext (SMS activity. This, "sent successfully!" , toast. Length _ length). show(); //Prompt success
}
});
}
At this point, the function of sending SMS has been introduced.
- Related articles
- 202 1 SMS
- What does Zhongan Small Loan do?
- Did lazy people push technology or did technology make lazy people?
- Send text messages to ask girls if they have boyfriends.
- Is it true that you received a short message from the court informing you of your breach of contract?
- What gifts will be given to China Mobile Business Office for spending money on China Mobile’s trip to China?
- A man sent me 500 messages. What should I do? Will the police handle it?
- What is the reason why ICBC mobile banking cannot transfer money?
- Is it true or not that a friendly law firm sends text messages?
- Is there no handling fee for Guizhou bank card to withdraw money from any bank?