├── app ├── .gitignore ├── libs │ ├── mail.jar │ ├── activation.jar │ ├── additionnal.jar │ ├── httpclient-4.5.3.jar │ ├── httpcore-4.4.6.jar │ └── commons-email-1.2.jar ├── src │ ├── main │ │ ├── res │ │ │ ├── values │ │ │ │ ├── strings.xml │ │ │ │ ├── colors.xml │ │ │ │ ├── dimens.xml │ │ │ │ └── styles.xml │ │ │ ├── mipmap-hdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-mdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxxhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── values-w820dp │ │ │ │ └── dimens.xml │ │ │ └── layout │ │ │ │ └── activity_main.xml │ │ ├── java │ │ │ └── com │ │ │ │ └── jiang │ │ │ │ └── android │ │ │ │ └── resend_sms │ │ │ │ ├── Common.java │ │ │ │ ├── model │ │ │ │ └── SmsInfo.java │ │ │ │ ├── service │ │ │ │ ├── SmsHandler.java │ │ │ │ ├── SmsService.java │ │ │ │ └── SmsObserver.java │ │ │ │ ├── SendPost.java │ │ │ │ ├── recever │ │ │ │ └── SmsReceiver.java │ │ │ │ ├── utils │ │ │ │ └── IntenetUtil.java │ │ │ │ ├── MainActivity.java │ │ │ │ ├── SendEmail.java │ │ │ │ └── SharePrefUtil.java │ │ └── AndroidManifest.xml │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── jiang │ │ │ └── android │ │ │ └── resend_sms │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── com │ │ └── jiang │ │ └── android │ │ └── resend_sms │ │ └── ExampleInstrumentedTest.java ├── proguard-rules.pro └── build.gradle ├── settings.gradle ├── launcher.sketch ├── release └── app-release_v1.0.apk ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .gitignore ├── gradle.properties ├── README.md ├── gradlew.bat └── gradlew /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | build 3 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | -------------------------------------------------------------------------------- /launcher.sketch: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiang111/ReSend-SMS/HEAD/launcher.sketch -------------------------------------------------------------------------------- /app/libs/mail.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiang111/ReSend-SMS/HEAD/app/libs/mail.jar -------------------------------------------------------------------------------- /app/libs/activation.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiang111/ReSend-SMS/HEAD/app/libs/activation.jar -------------------------------------------------------------------------------- /app/libs/additionnal.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiang111/ReSend-SMS/HEAD/app/libs/additionnal.jar -------------------------------------------------------------------------------- /app/libs/httpclient-4.5.3.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiang111/ReSend-SMS/HEAD/app/libs/httpclient-4.5.3.jar -------------------------------------------------------------------------------- /app/libs/httpcore-4.4.6.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiang111/ReSend-SMS/HEAD/app/libs/httpcore-4.4.6.jar -------------------------------------------------------------------------------- /release/app-release_v1.0.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiang111/ReSend-SMS/HEAD/release/app-release_v1.0.apk -------------------------------------------------------------------------------- /app/libs/commons-email-1.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiang111/ReSend-SMS/HEAD/app/libs/commons-email-1.2.jar -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 短信转发 3 | 4 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiang111/ReSend-SMS/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiang111/ReSend-SMS/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiang111/ReSend-SMS/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiang111/ReSend-SMS/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiang111/ReSend-SMS/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiang111/ReSend-SMS/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | .externalNativeBuild 10 | 123456.jks 11 | .idea 12 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Dec 28 10:00:20 PST 2015 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip 7 | -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/test/java/com/jiang/android/resend_sms/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.jiang.android.resend_sms; 2 | 3 | import org.junit.Test; 4 | 5 | /** 6 | * Example local unit test, which will execute on the development machine (host). 7 | * 8 | * @see Testing documentation 9 | */ 10 | public class ExampleUnitTest { 11 | @Test 12 | public void addition_isCorrect() throws Exception { 13 | 14 | 15 | boolean result = System.currentTimeMillis() - 1490148786880l > 1277770000; 16 | System.out.print(result+""); 17 | } 18 | } -------------------------------------------------------------------------------- /app/src/main/java/com/jiang/android/resend_sms/Common.java: -------------------------------------------------------------------------------- 1 | package com.jiang.android.resend_sms; 2 | 3 | /** 4 | * Created by jiang on 2017/4/20. 5 | */ 6 | 7 | public class Common { 8 | public static final String SMTP = "smtp_server"; 9 | public static final String SEND_TO = "send_to"; 10 | public static final String SEND_FROM = "send_from"; 11 | public static final String AUTHENTIATION_USER = "authentication_user"; 12 | public static final String AUTHENTIATION_PASSWD = "authentication_passwd"; 13 | public static final String SUBJEECT = "subject"; 14 | public static final String SSL_PORT = "ssl_port"; 15 | } 16 | -------------------------------------------------------------------------------- /app/src/main/java/com/jiang/android/resend_sms/model/SmsInfo.java: -------------------------------------------------------------------------------- 1 | package com.jiang.android.resend_sms.model; 2 | 3 | /** 4 | * Created by jiang on 2017/3/21. 5 | */ 6 | 7 | public class SmsInfo { 8 | public String _id = ""; 9 | public String thread_id = ""; 10 | public String smsAddress = ""; 11 | public String smsBody = ""; 12 | public String read = ""; 13 | public int action = 0;// 1代表设置为已读,2表示删除短信 14 | @Override 15 | public String toString() { 16 | return "SmsInfo [_id=" + _id + ", thread_id=" + thread_id 17 | + ", smsAddress=" + smsAddress + ", smsBody=" + smsBody 18 | + ", read=" + read + ", action=" + action + "]"; 19 | } 20 | 21 | 22 | } 23 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/jiang/androidsdk/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | org.gradle.jvmargs=-Xmx1536m 13 | 14 | # When configured, Gradle will run in incubating parallel mode. 15 | # This option should only be used with decoupled projects. More details, visit 16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 17 | # org.gradle.parallel=true 18 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/jiang/android/resend_sms/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.jiang.android.resend_sms; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumentation test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.jiang.android.resend_sms", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ReSend-SMS 2 | 建议使用163邮箱作为发件人,QQ邮箱发件太频繁需要验证 3 | 4 |    将手机接收到的短信以邮件的形式发送至指定邮箱。 5 | 6 | ### 参数配置 7 | 8 | >* 1. 请将你的邮箱开启smtp服务(具体开启方法请在 google 百度一下 163 为smtp.163.com QQ 为smtp.qq.com) 9 | >* 2. 由于代码中发送邮件开启了SSL加密,端口一般默认为465 10 | >* 3. 用户名一般为邮箱地址的名字去掉@后面几位(比如: 123#163.com 则用户名为123) 11 | >* 4. 部分邮箱开启smtp服务之后使用的验证密码并非邮件密码,而是授权码,请注意 12 | >* 5. 如果读取不到短信,注意授权相关的权限 13 | 14 | ### 注意事项 15 | >* 1. 邮件频繁发送的话,有的邮箱会自动归入垃圾箱内,如果长时间未收到提醒可以到垃圾箱找找 16 | >* 2. 请将APP加入手机白名单,让它常驻后台,这样才能准确接收到相关的短信,并发送 17 | >* 3. 该APP不会上传用户任何信息,可通过源码查看 18 | 19 | ### 下载 20 |    [点我下载](https://github.com/jiang111/ReSend-SMS/blob/master/release/app-release_v1.0.apk) 21 | 22 | ### License 23 | 24 | Copyright 2016 NewTab 25 | 26 | Licensed under the Apache License, Version 2.0 (the "License"); 27 | you may not use this file except in compliance with the License. 28 | You may obtain a copy of the License at 29 | 30 | http://www.apache.org/licenses/LICENSE-2.0 31 | 32 | Unless required by applicable law or agreed to in writing, software 33 | distributed under the License is distributed on an "AS IS" BASIS, 34 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 35 | See the License for the specific language governing permissions and 36 | limitations under the License. 37 | -------------------------------------------------------------------------------- /app/src/main/java/com/jiang/android/resend_sms/service/SmsHandler.java: -------------------------------------------------------------------------------- 1 | package com.jiang.android.resend_sms.service; 2 | 3 | import android.content.ContentValues; 4 | import android.content.Context; 5 | import android.net.Uri; 6 | import android.os.Handler; 7 | import android.os.Message; 8 | 9 | import com.jiang.android.resend_sms.model.SmsInfo; 10 | 11 | /** 12 | * Created by jiang on 2017/3/21. 13 | */ 14 | 15 | public class SmsHandler extends Handler { 16 | private Context mcontext; 17 | 18 | public SmsHandler(Context context) { 19 | this.mcontext = context; 20 | } 21 | 22 | @Override 23 | public void handleMessage(Message msg) { 24 | SmsInfo smsInfo = (SmsInfo) msg.obj; 25 | 26 | if (smsInfo.action == 1) { 27 | ContentValues values = new ContentValues(); 28 | values.put("read", "1"); 29 | mcontext.getContentResolver().update( 30 | Uri.parse("content://sms/inbox"), values, "thread_id=?", 31 | new String[]{smsInfo.thread_id}); 32 | } else if (smsInfo.action == 2) { 33 | // Uri mUri = Uri.parse("content://sms/"); 34 | // mcontext.getContentResolver().delete(mUri, "_id=?", 35 | // new String[] { smsInfo._id }); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /app/src/main/java/com/jiang/android/resend_sms/service/SmsService.java: -------------------------------------------------------------------------------- 1 | package com.jiang.android.resend_sms.service; 2 | 3 | import android.app.Service; 4 | import android.content.ContentResolver; 5 | import android.content.Intent; 6 | import android.net.Uri; 7 | import android.os.IBinder; 8 | import android.os.Process; 9 | import android.widget.Toast; 10 | 11 | /** 12 | * Created by jiang on 2017/3/21. 13 | */ 14 | 15 | public class SmsService extends Service { 16 | 17 | private SmsObserver mObserver; 18 | public static long currentTime; 19 | 20 | @Override 21 | public IBinder onBind(Intent intent) { 22 | return null; 23 | } 24 | 25 | @Override 26 | public void onCreate() { 27 | 28 | currentTime = System.currentTimeMillis(); 29 | Toast.makeText(this, "SmsService 服务器启动了....", Toast.LENGTH_LONG).show(); 30 | ContentResolver resolver = getContentResolver(); 31 | mObserver = new SmsObserver(resolver, new SmsHandler(this)); 32 | resolver.registerContentObserver(Uri.parse("content://sms"), true, mObserver); 33 | } 34 | 35 | @Override 36 | public void onDestroy() { 37 | super.onDestroy(); 38 | this.getContentResolver().unregisterContentObserver(mObserver); 39 | Process.killProcess(Process.myPid()); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /app/src/main/java/com/jiang/android/resend_sms/SendPost.java: -------------------------------------------------------------------------------- 1 | package com.jiang.android.resend_sms; 2 | 3 | import org.apache.http.NameValuePair; 4 | import org.apache.http.client.HttpClient; 5 | import org.apache.http.client.entity.UrlEncodedFormEntity; 6 | import org.apache.http.client.methods.HttpPost; 7 | import org.apache.http.impl.client.DefaultHttpClient; 8 | import org.apache.http.message.BasicNameValuePair; 9 | import org.apache.http.protocol.HTTP; 10 | 11 | import java.util.ArrayList; 12 | import java.util.List; 13 | 14 | /** 15 | * Created by jiang on 2017/7/9. 16 | */ 17 | 18 | public class SendPost { 19 | 20 | public void send(final String message) { 21 | new Thread(new Runnable() { 22 | @Override 23 | public void run() { 24 | postData(message); 25 | } 26 | }).start(); 27 | 28 | } 29 | 30 | private void postData(String message) { 31 | try { 32 | HttpClient httpclient = new DefaultHttpClient(); 33 | 34 | HttpPost httppost = new HttpPost("http://192.168.199.140:1024/send_sms"); 35 | List nameValuePairs = new ArrayList(1); 36 | nameValuePairs.add(new BasicNameValuePair("msg", message)); 37 | httppost.setHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8"); 38 | httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs, HTTP.UTF_8)); 39 | httpclient.execute(httppost); 40 | } catch (Exception e) { 41 | 42 | } 43 | 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 25 5 | buildToolsVersion "25.0.2" 6 | defaultConfig { 7 | applicationId "com.jiang.android.resend_sms" 8 | minSdkVersion 18 9 | targetSdkVersion 25 10 | versionCode 1 11 | versionName "1.0" 12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | packagingOptions { 21 | exclude 'META-INF/DEPENDENCIES' 22 | exclude 'META-INF/NOTICE' 23 | exclude 'META-INF/LICENSE' 24 | exclude 'META-INF/LICENSE.txt' 25 | exclude 'META-INF/NOTICE.txt' 26 | } 27 | } 28 | 29 | dependencies { 30 | compile fileTree(include: ['*.jar'], dir: 'libs') 31 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 32 | exclude group: 'com.android.support', module: 'support-annotations' 33 | }) 34 | compile 'com.android.support:appcompat-v7:25.3.0' 35 | testCompile 'junit:junit:4.12' 36 | compile 'com.nobrain.android.permissions:library:1.1.0' 37 | compile files('libs/mail.jar') 38 | compile files('libs/activation.jar') 39 | compile files('libs/additionnal.jar') 40 | compile files('libs/commons-email-1.2.jar') 41 | compile 'com.yanzhenjie:permission:1.0.5' 42 | compile files('libs/httpclient-4.5.3.jar') 43 | compile files('libs/httpcore-4.4.6.jar') 44 | } 45 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 23 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /app/src/main/java/com/jiang/android/resend_sms/service/SmsObserver.java: -------------------------------------------------------------------------------- 1 | package com.jiang.android.resend_sms.service; 2 | 3 | import android.content.ContentResolver; 4 | import android.database.ContentObserver; 5 | import android.database.Cursor; 6 | import android.net.Uri; 7 | import android.os.Message; 8 | import android.util.Log; 9 | 10 | import com.jiang.android.resend_sms.model.SmsInfo; 11 | 12 | /** 13 | * Created by jiang on 2017/3/21. 14 | */ 15 | 16 | public class SmsObserver extends ContentObserver { 17 | 18 | private ContentResolver mResolver; 19 | public SmsHandler smsHandler; 20 | 21 | public SmsObserver(ContentResolver mResolver, SmsHandler handler) { 22 | super(handler); 23 | this.mResolver = mResolver; 24 | this.smsHandler = handler; 25 | } 26 | 27 | @Override 28 | public void onChange(boolean selfChange) { 29 | Log.i("SmsObserver onChange ", "SmsObserver 短信有改变"); 30 | Cursor mCursor = mResolver.query(Uri.parse("content://sms/inbox"), 31 | new String[] { "_id", "address", "read", "body", "thread_id" }, 32 | "read=?", new String[] { "0" }, "date desc"); 33 | 34 | if (mCursor == null) { 35 | return; 36 | } else { 37 | while (mCursor.moveToNext()) { 38 | SmsInfo _smsInfo = new SmsInfo(); 39 | 40 | int _inIndex = mCursor.getColumnIndex("_id"); 41 | if (_inIndex != -1) { 42 | _smsInfo._id = mCursor.getString(_inIndex); 43 | } 44 | 45 | int thread_idIndex = mCursor.getColumnIndex("thread_id"); 46 | if (thread_idIndex != -1) { 47 | _smsInfo.thread_id = mCursor.getString(thread_idIndex); 48 | } 49 | 50 | int addressIndex = mCursor.getColumnIndex("address"); 51 | if (addressIndex != -1) { 52 | _smsInfo.smsAddress = mCursor.getString(addressIndex); 53 | } 54 | 55 | int bodyIndex = mCursor.getColumnIndex("body"); 56 | if (bodyIndex != -1) { 57 | _smsInfo.smsBody = mCursor.getString(bodyIndex); 58 | } 59 | 60 | int readIndex = mCursor.getColumnIndex("read"); 61 | if (readIndex != -1) { 62 | _smsInfo.read = mCursor.getString(readIndex); 63 | } 64 | 65 | // 根据你的拦截策略,判断是否不对短信进行操作;将短信设置为已读;将短信删除 66 | // TODO 67 | System.out.println("获取的短信内容为:"+_smsInfo.toString()); 68 | Log.i("SmsObserver ...", "获取的短信内容为:"+_smsInfo.toString()); 69 | Message msg = smsHandler.obtainMessage(); 70 | _smsInfo.action = 2;// 0不对短信进行操作;1将短信设置为已读;2将短信删除 71 | msg.obj = _smsInfo; 72 | smsHandler.sendMessage(msg); 73 | } 74 | } 75 | 76 | if (mCursor != null) { 77 | mCursor.close(); 78 | mCursor = null; 79 | } 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /app/src/main/java/com/jiang/android/resend_sms/recever/SmsReceiver.java: -------------------------------------------------------------------------------- 1 | package com.jiang.android.resend_sms.recever; 2 | 3 | import android.content.BroadcastReceiver; 4 | import android.content.Context; 5 | import android.content.Intent; 6 | import android.os.Bundle; 7 | import android.telephony.SmsMessage; 8 | import android.widget.Toast; 9 | 10 | import com.jiang.android.resend_sms.SendEmail; 11 | 12 | /** 13 | * Created by jiang on 2017/3/21. 14 | */ 15 | 16 | public class SmsReceiver extends BroadcastReceiver { 17 | private static final String TAG = "SmsReceiver"; 18 | private Context mContext; 19 | public static final String SMS_RECEIVED_ACTION = "android.provider.Telephony.SMS_RECEIVED"; 20 | public static final String SMS_DELIVER_ACTION = "android.provider.Telephony.SMS_DELIVER"; 21 | 22 | 23 | @Override 24 | public void onReceive(Context context, Intent intent) { 25 | this.mContext = context; 26 | try { 27 | String action = intent.getAction(); 28 | if (SMS_RECEIVED_ACTION.equals(action) || SMS_DELIVER_ACTION.equals(action)) { 29 | Toast.makeText(context, "开始接收短信.....", Toast.LENGTH_SHORT).show(); 30 | Bundle bundle = intent.getExtras(); 31 | if (bundle != null) { 32 | Object[] pdus = (Object[]) bundle.get("pdus"); 33 | if (pdus != null && pdus.length > 0) { 34 | SmsMessage[] messages = new SmsMessage[pdus.length]; 35 | for (int i = 0; i < pdus.length; i++) { 36 | byte[] pdu = (byte[]) pdus[i]; 37 | messages[i] = SmsMessage.createFromPdu(pdu); 38 | } 39 | StringBuffer buffer = new StringBuffer(); 40 | String sender = null; 41 | for (SmsMessage message : messages) { 42 | buffer.append(message.getMessageBody()); 43 | sender = message.getOriginatingAddress(); 44 | this.abortBroadcast(); 45 | } 46 | 47 | sendSMS("发件人:" + sender + "\n 内容:" + buffer.toString()); 48 | 49 | } 50 | } 51 | 52 | } 53 | } catch (Exception e) { 54 | e.printStackTrace(); 55 | Toast.makeText(mContext, e.getMessage(), Toast.LENGTH_SHORT).show(); 56 | } 57 | } 58 | 59 | public void sendSMS(String message) { 60 | // if (IntenetUtil.getNetworkState(mContext) == IntenetUtil.NETWORN_WIFI) { 61 | // WifiManager wifiManager = (WifiManager) mContext.getSystemService(Context.WIFI_SERVICE); 62 | // WifiInfo wifiInfo = wifiManager.getConnectionInfo(); 63 | // final String ssid = wifiInfo.getSSID(); 64 | // if (ssid.startsWith("\"HiWiFi")) { 65 | // Log.i(TAG, "sendSMS: 发送微信"); 66 | // new SendPost().send(message); 67 | // return; 68 | // } 69 | // } 70 | new SendEmail().send(mContext, message); 71 | 72 | } 73 | } 74 | 75 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 13 | 14 | 15 | 18 | 19 | 20 | 24 | 25 | 31 | 32 | 39 | 40 | 46 | 47 | 53 | 54 | 60 | 61 | 67 | 68 | 74 | 75 |