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
When doing a mobile phone adaptation, encountered a very strange problem, in 1080x720 's phone can display the replacement ic_launcher.png icon, but in 1920x1080 's phone display ic_ Launcher.png is still the default icon, and after checking that it does not include the default Ic_launcher.png icon throughout the project, what is the
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
PopupMenu is a very lightweight component in Android. Compared to Popupwindow, PopupMenu's customizable capabilities are small, but easier to use.First on:The following functions are implemented in this example:1. Force the icon for the menu item to appear.By default, the PopupMenu icon is not displayed, and Android do
PopupMenu is a very lightweight component in Android. Compared with Popupwindow, PopupMenu's ability to define itself is smaller, but it is more convenient to use.First on:The following features are implemented in this example:1. Force the icon for the menu item to appear.The default state. The icon for PopupMenu is not displayed. And
Today met very speechless very pit demand, said to be installed in the application according to the parameters of the different dynamic generation of desktop icons, which is basically impossible in Android, there is a stackoverflow on the following sentence:You cannot change the application icon (or the Android manifest, or any other application resource for that
1. Based on the broadcast accept SMS 1.1 principle Android receives a text message and the system sends a Android.provider.Telephony.SMS_RECEIVED broadcast. Put it in bundle (Intent.extras), bundle can be understood as a map, text message using "PDUs" as the key, PDUs should be protocol description units shorthand, that is, a set of text messages. Android does no
Android System SMS Source Library Click to open the linkAndroid System SMS Source Click to open the linkThe new project needs to do the SMS module function, this SMS module non-android system
--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
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"
. 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 gentleman wants to be in the speech and is sensitive to the line.-The Analects of Confucius Recently, the body is a bit uncomfortable, only to notice the body is really the most important , no matter how busy we are, we must rest on time, insist on running, exercise, do some of the cervical spine and so on, do not let us earn money to see the doctor, we come together to insist Ah, do not let the young blinded our eyes.In the Android development of
. Event_get_verification_code) {Toast.maketext (Getapplicationcontext (), "Authenticode sent", Toast.length_short). Show ();} else {((throwable) data). Printstacktrace ();}}}}; @Overrideprotected void OnDestroy () {Super.ondestroy ();//this.unregisterreceiver (Smsbroadcastreceiver); Smssdk.unregisteralleventhandler ();}Summary At this point, a text verification function has been implemented. The platform has some limitations and the app must be networked. The verification code can only be 4 bits
The SMS listener obtains the content, time, sender, and other information of the information when it receives the information, and then processes the information, which can shield the user from seeing the information, forwarding it, or sending it to the web for processing. Exciting function ..
Let's take a look at its implementation principles.
In fact, SMS reception is implemented by the broadcast receiver
This article is an example of how Android sends SMS. Share to everyone for your reference, specific as follows:
SMS and phone calls are the basic features of Android phones, and here are examples of how Android can deliver text messages.
The program looks like this:
I
permissions:then hit "Application" to add the following activity:Five, running exampleThen click to get the verification code, the text message will be automatically entered into the verification code edittext.SMS Verification code can also be used to retrieve the password function, you can set the intent jump on their own can be.Like a friend can pay attention to me! Thank you! Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
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.