Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize the function of short message Editor in Android

2025-03-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains "how to achieve the short message editor function in Android". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to achieve the short message editor function in Android".

AndroidManifest.xml

Activity_main.xml

MainActivity.java

Public class MainActivity extends AppCompatActivity {private int phoneNum; private String textSMS; private String currentTime; private Button sendMessage; private Button getTime; private EditText getPhone; private EditText getMessage; @ Override protected void onCreate (Bundle savedInstanceState) {super.onCreate (savedInstanceState); setContentView (R.layout.activity_main); / / registered control sendMessage = (Button) findViewById (R.id.send_message); getTime = (Button) findViewById (R.id.get_time) GetPhone = (EditText) findViewById (R.id.get_phone); getMessage = (EditText) findViewById (R.id.get_message); / / get the current time getTime.setOnClickListener (new View.OnClickListener () {@ Override public void onClick (View v) {textSMS = getMessage.getText () .toString (); SimpleDateFormat formatter = new SimpleDateFormat ("yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy Date curDate = new Date (System.currentTimeMillis ()); / / get the current time currentTime = formatter.format (curDate); textSMS = textSMS + currentTime; getMessage.setText (textSMS);}}) / / send SMS sendMessage.setOnClickListener (new View.OnClickListener () {@ Override public void onClick (View v) {if (TextUtils.isEmpty (getPhone.getText (). ToString () {Toast.makeText (MainActivity.this, "phone number not filled in", Toast.LENGTH_SHORT) .show (); return } if (TextUtils.isEmpty (getMessage.getText (). ToString ()) {Toast.makeText (MainActivity.this, "SMS content is not filled in", Toast.LENGTH_SHORT) .show (); return;} / / get the phone number and text message content phoneNum = Integer.parseInt (getPhone.getText (). ToString ()); textSMS = getMessage.getText (). ToString () / / enable multithreading Thread thread = new Thread () {@ Override public void run () {ContentResolver resolver = getContentResolver (); ContentValues values = new ContentValues (); values.put ("address", phoneNum); values.put ("type", 1); values.put ("date", System.currentTimeMillis ()) Values.put ("body", textSMS); resolver.insert (Uri.parse ("content://sms"), values);}}; thread.start (); Toast.makeText (MainActivity.this, "SMS generated successfully", Toast.LENGTH_SHORT). Show ();}}) }} Thank you for your reading. The above is the content of "how to achieve the SMS editor function in Android". After the study of this article, I believe you have a deeper understanding of how to achieve the SMS editor function in Android, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report