First, this is the flow of this stuff:Whether you use mob or mobile or your own SMS interface is the same, in the sending verification code part to request, and then the server returned to you a short message, and then you deal with it, to achieve the effect.This is the only need to listen to the database changes in the text message can be, and to listen to the one you want.First,Contentobserverimportandroi
Basic principle: Through the Contentobserver Observer listens to the SMS database change, when has the change detects whether is from the specified number the text message, if is the word to obtain the necessary content through the regular expression, then the code (*^__^*) hehe ... :1 /**2 * 3 * @ClassName: Smscontent4 * @Description: SMS Listening class5 * @au
In our current development app process, when the user registers, the SMS authentication is the essential operation, here we are uses a free third party text message authentication Sdk-mop
First look at the effect chart
Get Appkey and Appsecret
First go to the official website, login (no account of their own to register a). Mouse to move to the right avatar, click into the background.
Website Home
Select SECURITYCODESDK.
Select
SMS bug of android content observer,Steps:1. Get the content observer ContentResolver contentResolver = getContentResolver ();2. Register and observe the observed content (that is, add the observer in the android text message)// Uri Short Message Address // true indicates that the SMS address meets the requirements. fa
(pdus.
Protected void dispatchPdus (byte [] [] pdus ){
Intent intent = new Intent (Intents. SMS_RECEIVED_ACTION );
Intent. putExtra ("pdus", pdus );
Dispatch (intent, "android. permission. RECEIVE_SMS ");
}
Void dispatch (Intent intent, String permission ){
// Hold a wake lock for WAKE_LOCK_TIMEOUT seconds, enough to give any
// Receivers time to take their own wake locks.
MWakeLock. acquire (WAKE_LOCK_TIMEOUT );
Mcontext. sendorderedbroadcast (inte
SMS messages of Android are stored in the SQLite database in the Android system, but are not accessible to other programs (Security Mechanism of Android)
Now we are reading SMS messages from our mobile phone, saving them in our ow
Android Basics Getting Started Tutorial--10.2 Smsmanager (SMS manager)tags (space delimited): Android Basics Getting Started TutorialIntroduction to this section:
This section brings in the Android Smsmanager (short-term manager), known as the name, is used to manage mobile phone messages,And this kind of appl
() {@Override Public voidOnReceive (Context context, Intent Intent) {//determine if the text message was sent successfully Switch(Getresultcode ()) { CaseActivity.RESULT_OK:Toast.makeText (Context,"SMS sent Successfully", Toast.length_short). Show (); Break; default: Toast.maketext (Context,"Send Failed", Toast.length_long). Show (); Break; } } }; Private StaticBroadcastreceiver receiver =NewBroadcastreceiver () {@Override P
method in the Buttononclick class (Secretly lazy O (∩_∩) o~)
In this code, the first is to get the phone number telephone and SMS content sendmessages, and then through the Smsmanager class to achieve the function of text messaging, through the Smsmanager.getdefault () method to get the SMS Send manager, Then through the SMS Send Manager's Dividemessage me
Android broadcasts Android.provider.Telephony.SMS_RECEIVED messages when it receives text messages, so you can receive text messages by defining a receiver and listening to the message.
You can also add a priority to Intent-filter:
This allows the application to receive the Android.provider.Telephony.SMS_RECEIVED message before the system because of higher priority.Java files:
Package com.hzhi.smsReceiver;
Import Java.text.Simple
Now the development of the function needs to jump directly to the dial-up, contact, SMS interface and so on, looking for a lot of information, I organized a bit.
1, jump to the Dial-up interface, the code is as follows:
1) Direct dialing
Intent Intentphone = new Intent (Intent.action_call, Uri.parse ("Tel:" + phonenumber));
StartActivity (Intentphone);
2) jump to the Dial-up interface
Intent Intent = newintent (Intent.actio
Usage scenarios:1, the system receives the text message to identify, is the advertisement or is the fraud and so on2, to filter the content of the message or to extract the content, such as verification code extraction3, the system SMS interception, even the system itself is not allowed to receive (will not appear in the system data, there will be no system SMS notification bar prompt) Note:1, the system
I. Preface
Now the app basically needs to use the SMS function, when you register or have a message when you need to send a text message to the user, but for personal developers, to buy a third party SMS service is a bit extravagant, very good is mob for us to provide a free text message authentication Code service function, I am not playing ads, I really think this service is very good. Then the following
--smsmanager of system services provided by Android (SMS manager) --Reprint Please specify Source: Coder-pigSmsmanager Related introduction and use diagram:Of course, in order to facilitate everyone, put the code sticky, you do not bother to write code:Copy and paste it when you need it!1) Call the system to send SMS functions:public void Sendsmsto (String phone
. Registerreceiver (NewBroadcastreceiver () {@Override Public voidonreceive (Context _context, Intent _intent) {toast.maketext (mainactivity. This, "The addressee has successfully received the message.", Toast.length_short). Show (); } }, NewIntentfilter (delivered_sms_action));Don't forget the question of permissions:Description of the parameters for sending SMS:Smsmanager.sendtextmessage (destinationaddress, scaddress, text, sentintent, deliveryintent)--destinationaddress: Targ
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.