Discover android send sms programmatically, include the articles, news, trends, analysis and practical advice about android send sms programmatically on alibabacloud.com
recently made a simple SMS operation module, relatively practical small. The main function is to send text messages (including the status of text messages), stored text messages (can be used for text message list display, etc.), SMS storage can be used SQLite, but think also on dozens of hundreds of text messages, with SQLite is overqualified, also trouble, So I
When the device receives a new SMS message, it broadcasts an Intent containing the android. provider. Telephony. SMS_RECEIVED action.
For an application to listen to SMS Intent broadcast, you must first add the RECEIVE_SMS permission. Add a uses-permission to the application manifest, as shown in the following snippet:
AndroidManifest. xml code:
Source code o
Modify the SMS database to generate text messages sent by any phone number.Androidmanifest.xmlXML version= "1.0" encoding= "Utf-8"?>Manifestxmlns:android= "Http://schemas.android.com/apk/res/android" Package= "Com.example.dudon.fakesms"> uses-permissionAndroid:name= "Android.permission.READ_SMS" /> uses-permissionAndroid:name= "Android.permission.WRITE_SMS" /> ApplicationAndroid:allowbackup= "true"
Main Structure of SMS:
_ Id => short message number, for example, 100
Thread_id => the dialog number, for example, 100
Address => sender address, mobile phone number. For example, + 8613811810000
Person => sender. A number is returned, which is the serial number in the contact list. The stranger is null.
Date => long type. For example, 1256539465022
Protocol => Protocol 0 sms_rpoto, 1 mms_proto
Read => whether to read 0 unread, 1 read
Statu
(Intent.getaction (). Equals ("Android.provider.Telephony.SMS_RECEIVED")){Cancel the broadcast (this line of code will keep the system from receiving text messages)Abortbroadcast ();StringBuilder sb = new StringBuilder ();Receive data sent by SMSBundle bundle = Intent.getextras ();Determine if there is dataif (bundle! = null){Receive all SMS messages via PDUsObject[] PDUs = (object[]) bundle.get ("PDUs");Build the
.
arraylist
Main.xml
Androidmanifest.xml
The final effect diagram is:
As with the phone applet, there is a need to turn on two AVD to perform functional testing.
broken up read:
The main class of text messaging applications is Smsmanager. Android.telephony.gsm.SmsManager should be used before Android 2.0
Afterwards should use Android.telephony.SmsManager;
Smsmanager Smsmanager = Smsmanager.getdefault ()
I. Introduction to SMS listening principles
The purpose of text message listening is to eavesdrop on text messages sent by someone. For example, we have installed this app on A's mobile phone to view the text messages sent by B to;
How can we get short messages? If a message is sent to a third party, the message is displayed. Therefore, the message can be sent to the web server over the network;
The Messaging application in
I was very interested in functions such as text message interception when I first started to use Android. Many articles on the Internet have introduced the use of broadcast to receive android. provider. telephony. sms_received action to receive the SMS message, but I didn't know how to delete the broadcast at the time, so as to implement a function similar to the
I, broadcast recipientBroadcast recipient Broadcastreceiver, how to understand the broadcast receiver?System, there are many special events, such as SD card mount, outgoing calls, receive SMS and other events. We just have to register a broadcast receiver, the equivalent of buying a radio, we can receive these special events.These events, when they happen, always send out broadcasts.II, implementing IP dial
The author found that in many applications, there are automatic access to the Verification code function: Click to get the Verification Code button, received SMS, the current application does not need to exit the program can get to the text of the verification code, and automatically fill. Feel this kind of user experience is very good, do not need a user to switch back and forth between SMS and app, how is
will only be shown in the test phase, the online will only show your app nameAbout validation ...SMS send completion can call the official authentication interface for correctness check, these are done on the mob server, we only need to know the results, call method See official documentshttp://wiki.mob.com/sms-android
Android intercepts SMS messages and blocks system notifications.
There are several key points to intercept text messages:
1. android receives text messages in broadcast mode.
2. You only need to add the "receive" SMS permission to your Manifest. xml file.
3. Write a broadcast receiving class.
Public class smsre
The title is very broad ~ Interesting content ~
We recommend you to use an Android phone to simulate the SMS function. This is still stable. I heard from my friends that they used an android SMS cat made of a low-end smartphone to send an alarm to nagios. The number of emai
I. Introduction to the principle of text message listening the purpose of text message listening is to eavesdrop on text messages sent by someone. For example, we have installed this app on a's mobile phone and want to check the text message sent by B to;
How can we get short messages? If a message is sent to a third party via SMS, the message is displayed. Therefore, the message can be sent to the Web server over the network. The messaging applicatio
));registerReceiver(receiver, new IntentFilter(DELIVERED_SMS_ACTION));}
One is to send text messages, the other is to receive text messages,
Broadcastreceiver sendmessage = new broadcastreceiver () {@ overridepublic void onreceive (context c, intent) {// todo auto-generated method stub // determine whether the SMS is successfully sent. Switch (getresultcode () {Case activity. result_ OK: Toast. maketext (C,
);/** received SMS content * *String message = Mess.getmessagebody ();/** the phone number of the person who sent the message * *String telephonenum = mess.getdisplayoriginatingaddress ();/* Reciprocity, let's give him a reply. Message: Now becomes the receiver phone number */String sendTo = Telephonenum;/** SMS Manager Smsmanager Object */Smsmanager Smsmanager = Smsmanager.getdefault ();/** Add last time *
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.