Android supports sending empty text messages

Source: Internet
Author: User

Android supports sending empty text messages
Method:
A) modify the AP:
1. Modify isPreparedForSending () in ComposeMessageActivity. java as follows (the deleted code can also be commented out)
Private boolean isPreparedForSending (){
If (isRecipientsEditorVisible ())
{
String recipientText = mRecipientsEditor. getText () = null ?"" : MRecipientsEditor. getText (). toString ();
Return mSimCount> 0 &&! TextUtils. isEmpty (recipientText );
} Else {
Return mSimCount> 0;
}
}
2. Add SmsSingleRecipientSender. java
Import android. text. TextUtils;
In the public boolean sendMessage (long token, int simId) function, add "int messageCount = messages. size ();" before
If (TextUtils. isEmpty (mMessageText )){
Messages. add ("");
}
3. Modify the queueMessage () method of SmsMessageSender. java
Remove the judgment on mMessageText = null.

B) The Framework must be integrated with the Patch. The changes in the Patch are as follows:
In alps \ mediatek \ frameworks-ext \ base \ telephony \ java \ android \ telephony \ gemini \ GeminiSmsManager
IsValidParameters (String destinationAddress, String parts, PendingIntent sentIntent) method,
Remove the part that determines parts is empty in this method.
If (parts = null | parts. size () <1 ){
// Throw new IllegalArgumentException ("Invalid message body"); <--- block this statement.
}

In addition, if the information is received when the screen is disabled, the message is displayed directly. In the hope that the DialogModeActivity interface can also be used to reply to blank messages, in addition to the above modification, modify the following code:
Modify DialogModeActivity. java as follows:
1. Modify private void updateSendButtonState () {about 2242 rows, and change if (len> 0) to if (len> = 0). The modification is as follows:
Private void updateSendButtonState (){
Boolean enable = false;
Int len = mReplyEditor. getText (). toString (). length ();
MmsLog. d (TAG, "DialogModeActivity. updateSendButtonState (): len =" + len );
If (mSendButton! = Null ){
If (len> = 0) {// modify for send blank sms
MmsLog. d (TAG, "updateSendButtonState (): mSimCount =" + mSimCount );
2. Modify:
OnPreMessageSent (){
MmsLog. d (TAG, "DialogModeActivity. onPreMessageSent ");
If (mUris! = Null &&! MUris. isEmpty ()){
RunOnUiThread (mResetMessageRunnable );
}

3. Runnable mResetMessageRunnable = new Runnable (){
Public void run (){
If (mUris! = Null &&! MUris. isEmpty ()){
MmsLog. d (TAG, "mResetMessageRunnable. run ");
ResetMessage ();
}
}
};
Note: For mobile phones of The KK version, the modification method is slightly changed. There are two main changes:
1. The modified queueMessage () method of SmsMessageSender. java removes the judgment on MessageText = null ==>
Modify the queueMessage () method of SmsMessageSender. java to remove the (mMessageText = null) | mMessageText. isEmpty () Judgment
2. This file is not found in GeminiSmsManager. java KK. Change it to ==>
Packages/apps/Mms/src/com/mediatek/encapsulation/android/telephony/gemini/EncapsulatedGeminiSmsManager. java
Frameworks/opt/telephony/src/java/android/telephony/SmsManager. java
Mediatek/frameworks/opt/telephony/src/java/com/mediatek/telephony/SmsManagerEx. java
The modification method is the same as that of JB:
If (parts = null | parts. size () <1 ){
// Throw new IllegalArgumentException ("Invalid message body"); <--- block this statement.
}

Related Article

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.