├── 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 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
--------------------------------------------------------------------------------
/app/src/main/java/com/jiang/android/resend_sms/utils/IntenetUtil.java:
--------------------------------------------------------------------------------
1 | package com.jiang.android.resend_sms.utils;
2 |
3 | import android.content.Context;
4 | import android.net.ConnectivityManager;
5 | import android.net.NetworkInfo;
6 | import android.telephony.TelephonyManager;
7 |
8 | /**
9 | * Created by jiang on 2017/7/9.
10 | */
11 |
12 | public class IntenetUtil {
13 |
14 | //没有网络连接
15 | public static final int NETWORN_NONE = 0;
16 | //wifi连接
17 | public static final int NETWORN_WIFI = 1;
18 | //手机网络数据连接类型
19 | public static final int NETWORN_2G = 2;
20 | public static final int NETWORN_3G = 3;
21 | public static final int NETWORN_4G = 4;
22 | public static final int NETWORN_MOBILE = 5;
23 |
24 | /**
25 | * 获取当前网络连接类型
26 | *
27 | * @param context
28 | * @return
29 | */
30 | public static int getNetworkState(Context context) {
31 | //获取系统的网络服务
32 | ConnectivityManager connManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
33 |
34 | //如果当前没有网络
35 | if (null == connManager)
36 | return NETWORN_NONE;
37 |
38 | //获取当前网络类型,如果为空,返回无网络
39 | NetworkInfo activeNetInfo = connManager.getActiveNetworkInfo();
40 | if (activeNetInfo == null || !activeNetInfo.isAvailable()) {
41 | return NETWORN_NONE;
42 | }
43 |
44 | // 判断是不是连接的是不是wifi
45 | NetworkInfo wifiInfo = connManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
46 | if (null != wifiInfo) {
47 | NetworkInfo.State state = wifiInfo.getState();
48 | if (null != state)
49 | if (state == NetworkInfo.State.CONNECTED || state == NetworkInfo.State.CONNECTING) {
50 | return NETWORN_WIFI;
51 | }
52 | }
53 |
54 | // 如果不是wifi,则判断当前连接的是运营商的哪种网络2g、3g、4g等
55 | NetworkInfo networkInfo = connManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
56 |
57 | if (null != networkInfo) {
58 | NetworkInfo.State state = networkInfo.getState();
59 | String strSubTypeName = networkInfo.getSubtypeName();
60 | if (null != state)
61 | if (state == NetworkInfo.State.CONNECTED || state == NetworkInfo.State.CONNECTING) {
62 | switch (activeNetInfo.getSubtype()) {
63 | //如果是2g类型
64 | case TelephonyManager.NETWORK_TYPE_GPRS: // 联通2g
65 | case TelephonyManager.NETWORK_TYPE_CDMA: // 电信2g
66 | case TelephonyManager.NETWORK_TYPE_EDGE: // 移动2g
67 | case TelephonyManager.NETWORK_TYPE_1xRTT:
68 | case TelephonyManager.NETWORK_TYPE_IDEN:
69 | return NETWORN_2G;
70 | //如果是3g类型
71 | case TelephonyManager.NETWORK_TYPE_EVDO_A: // 电信3g
72 | case TelephonyManager.NETWORK_TYPE_UMTS:
73 | case TelephonyManager.NETWORK_TYPE_EVDO_0:
74 | case TelephonyManager.NETWORK_TYPE_HSDPA:
75 | case TelephonyManager.NETWORK_TYPE_HSUPA:
76 | case TelephonyManager.NETWORK_TYPE_HSPA:
77 | case TelephonyManager.NETWORK_TYPE_EVDO_B:
78 | case TelephonyManager.NETWORK_TYPE_EHRPD:
79 | case TelephonyManager.NETWORK_TYPE_HSPAP:
80 | return NETWORN_3G;
81 | //如果是4g类型
82 | case TelephonyManager.NETWORK_TYPE_LTE:
83 | return NETWORN_4G;
84 | default:
85 | //中国移动 联通 电信 三种3G制式
86 | if (strSubTypeName.equalsIgnoreCase("TD-SCDMA") || strSubTypeName.equalsIgnoreCase("WCDMA") || strSubTypeName.equalsIgnoreCase("CDMA2000")) {
87 | return NETWORN_3G;
88 | } else {
89 | return NETWORN_MOBILE;
90 | }
91 | }
92 | }
93 | }
94 | return NETWORN_NONE;
95 | }
96 |
97 | }
98 |
--------------------------------------------------------------------------------
/app/src/main/java/com/jiang/android/resend_sms/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.jiang.android.resend_sms;
2 |
3 | import android.Manifest;
4 | import android.content.Intent;
5 | import android.os.Bundle;
6 | import android.support.v7.app.AppCompatActivity;
7 | import android.view.View;
8 | import android.widget.Button;
9 | import android.widget.EditText;
10 | import android.widget.Toast;
11 |
12 | import com.jiang.android.resend_sms.service.SmsService;
13 | import com.yanzhenjie.permission.AndPermission;
14 |
15 | public class MainActivity extends AppCompatActivity {
16 |
17 | private Intent intentService;
18 |
19 | @Override
20 | protected void onCreate(Bundle savedInstanceState) {
21 | super.onCreate(savedInstanceState);
22 | setContentView(R.layout.activity_main);
23 |
24 | initView();
25 | requestPermission();
26 |
27 | startService();
28 |
29 | }
30 |
31 | private void initView() {
32 | final EditText hostName = $(R.id.host);
33 | final EditText port = $(R.id.port);
34 | final EditText user = $(R.id.send_user);
35 | final EditText passwd = $(R.id.send_passwd);
36 | final EditText subject = $(R.id.send_subject);
37 | final EditText from = $(R.id.send_from);
38 | final EditText to = $(R.id.send_to);
39 | Button save = $(R.id.send_save);
40 | String hostNameS = SharePrefUtil.getString(MainActivity.this, Common.SMTP, "");
41 | int postS = SharePrefUtil.getInt(MainActivity.this, Common.SSL_PORT, 0);
42 | String userS = SharePrefUtil.getString(MainActivity.this, Common.AUTHENTIATION_USER, "");
43 | String passwdS = SharePrefUtil.getString(MainActivity.this, Common.AUTHENTIATION_PASSWD, "");
44 | String subjectS = SharePrefUtil.getString(MainActivity.this, Common.SUBJEECT, "");
45 | String fromS = SharePrefUtil.getString(MainActivity.this, Common.SEND_FROM, "");
46 | String toS = SharePrefUtil.getString(MainActivity.this, Common.SEND_TO, "");
47 |
48 |
49 | hostName.setText(hostNameS);
50 | user.setText(userS);
51 | passwd.setText(passwdS);
52 | subject.setText(subjectS);
53 | from.setText(fromS);
54 | to.setText(toS);
55 | if (postS != 0) {
56 | port.setText(postS + "");
57 | }
58 | save.setOnClickListener(new View.OnClickListener() {
59 | @Override
60 | public void onClick(View v) {
61 | SharePrefUtil.saveString(MainActivity.this, Common.SMTP, hostName.getText().toString());
62 | SharePrefUtil.saveString(MainActivity.this, Common.AUTHENTIATION_USER, user.getText().toString());
63 | SharePrefUtil.saveString(MainActivity.this, Common.AUTHENTIATION_PASSWD, passwd.getText().toString());
64 | SharePrefUtil.saveString(MainActivity.this, Common.SUBJEECT, subject.getText().toString());
65 | SharePrefUtil.saveString(MainActivity.this, Common.SEND_FROM, from.getText().toString());
66 | SharePrefUtil.saveString(MainActivity.this, Common.SEND_TO, to.getText().toString());
67 | SharePrefUtil.saveInt(MainActivity.this, Common.SSL_PORT, Integer.valueOf(port.getText().toString()));
68 |
69 | SendEmail.clear();
70 | Toast.makeText(MainActivity.this, "保存成功", Toast.LENGTH_SHORT).show();
71 |
72 | }
73 | });
74 |
75 | }
76 |
77 |
78 | public T $(int id) {
79 | return (T) findViewById(id);
80 | }
81 |
82 | private void requestPermission() {
83 | //判断Android版本是否大于23
84 | AndPermission.with(this)
85 | .requestCode(100)
86 | .permission(Manifest.permission.READ_SMS,
87 | Manifest.permission.SEND_SMS,
88 | Manifest.permission.BROADCAST_SMS,
89 | Manifest.permission.RECEIVE_SMS
90 | )
91 | .send();
92 | }
93 |
94 |
95 | private void startService() {
96 | intentService = new Intent(MainActivity.this, SmsService.class);
97 | startService(intentService);
98 | }
99 | }
100 |
--------------------------------------------------------------------------------
/app/src/main/java/com/jiang/android/resend_sms/SendEmail.java:
--------------------------------------------------------------------------------
1 | package com.jiang.android.resend_sms;
2 |
3 | import android.content.Context;
4 | import android.os.Handler;
5 | import android.os.Looper;
6 | import android.text.TextUtils;
7 | import android.util.Log;
8 | import android.widget.Toast;
9 |
10 | import org.apache.commons.mail.HtmlEmail;
11 |
12 | import java.util.concurrent.ExecutorService;
13 | import java.util.concurrent.Executors;
14 |
15 | /**
16 | * Created by jiang on 2017/4/20.
17 | */
18 |
19 | public class SendEmail {
20 | private static Handler mHandler = new Handler(Looper.getMainLooper());
21 |
22 | public static ExecutorService executorService = Executors.newCachedThreadPool();
23 |
24 | private static String sendTo = "";
25 | private static String sendFrom = "";
26 | private static String user = "";
27 | private static String passwd = "";
28 | private static int ssLPort = 0;
29 | private static String hostName = "";
30 | private static String subject = "";
31 |
32 | public SendEmail() {
33 | }
34 |
35 | public void send(final Context context, final String body) {
36 |
37 | executorService.submit(new Runnable() {
38 | @Override
39 | public void run() {
40 | try {
41 | initConfig(context);
42 | if (TextUtils.isEmpty(sendTo) ||
43 | TextUtils.isEmpty(sendFrom) ||
44 | ssLPort == 0 ||
45 | TextUtils.isEmpty(user) ||
46 | TextUtils.isEmpty(passwd)) {
47 | mHandler.post(new Runnable() {
48 | @Override
49 | public void run() {
50 | Toast.makeText(context, "请先配置账号", Toast.LENGTH_SHORT).show();
51 | }
52 | });
53 | return;
54 | }
55 | Log.i(TAG, "send: " + body);
56 | HtmlEmail email = new HtmlEmail();
57 | email.setHostName(hostName);
58 | email.setSmtpPort(ssLPort);
59 | email.setSSL(true);
60 | email.setCharset("utf8");
61 | email.addTo(sendTo);
62 | email.setFrom(sendFrom);
63 | email.setAuthentication(user, passwd);
64 | email.setSubject(TextUtils.isEmpty(subject) ? "你有新短信了" : subject);
65 | email.setMsg(TextUtils.isEmpty(body) ? "null" : body);
66 | email.send();
67 | mHandler.post(new Runnable() {
68 | @Override
69 | public void run() {
70 | Toast.makeText(context, "邮件发送成功", Toast.LENGTH_SHORT).show();
71 | }
72 | });
73 | } catch (final Exception e) {
74 | e.printStackTrace();
75 | mHandler.post(new Runnable() {
76 | @Override
77 | public void run() {
78 | Toast.makeText(context, "邮件发送失败:" + e.getMessage(), Toast.LENGTH_SHORT).show();
79 | }
80 | });
81 |
82 | }
83 | }
84 | });
85 |
86 | }
87 |
88 | public static void initConfig(Context context) {
89 | if (TextUtils.isEmpty(sendFrom)) {
90 | sendFrom = SharePrefUtil.getString(context.getApplicationContext(),
91 | Common.SEND_FROM, "");
92 | }
93 | if (TextUtils.isEmpty(sendTo)) {
94 | sendTo = SharePrefUtil.getString(context.getApplicationContext(),
95 | Common.SEND_TO, "");
96 | }
97 | if (TextUtils.isEmpty(user)) {
98 | user = SharePrefUtil.getString(context.getApplicationContext(),
99 | Common.AUTHENTIATION_USER, "");
100 | }
101 | if (TextUtils.isEmpty(passwd)) {
102 | passwd = SharePrefUtil.getString(context.getApplicationContext(),
103 | Common.AUTHENTIATION_PASSWD, "");
104 | }
105 | if (ssLPort == 0) {
106 | ssLPort = SharePrefUtil.getInt(context.getApplicationContext(),
107 | Common.SSL_PORT, 0);
108 | }
109 | if (TextUtils.isEmpty(hostName)) {
110 | hostName = SharePrefUtil.getString(context.getApplicationContext(),
111 | Common.SMTP, "");
112 | }
113 | if (TextUtils.isEmpty(subject)) {
114 | subject = SharePrefUtil.getString(context.getApplicationContext(),
115 | Common.SUBJEECT, "");
116 | }
117 |
118 | }
119 |
120 | public static void clear() {
121 | sendTo = null;
122 | sendFrom = null;
123 | user = null;
124 | passwd = null;
125 | ssLPort = 0;
126 | hostName = null;
127 | subject = null;
128 |
129 | }
130 |
131 | private static final String TAG = "SendEmail";
132 | }
133 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/app/src/main/java/com/jiang/android/resend_sms/SharePrefUtil.java:
--------------------------------------------------------------------------------
1 | /**
2 | * created by jiang, 11/9/15
3 | * Copyright (c) 2015, jyuesong@gmail.com All Rights Reserved.
4 | * * # #
5 | * # _oo0oo_ #
6 | * # o8888888o #
7 | * # 88" . "88 #
8 | * # (| -_- |) #
9 | * # 0\ = /0 #
10 | * # ___/`---'\___ #
11 | * # .' \\| |# '. #
12 | * # / \\||| : |||# \ #
13 | * # / _||||| -:- |||||- \ #
14 | * # | | \\\ - #/ | | #
15 | * # | \_| ''\---/'' |_/ | #
16 | * # \ .-\__ '-' ___/-. / #
17 | * # ___'. .' /--.--\ `. .'___ #
18 | * # ."" '< `.___\_<|>_/___.' >' "". #
19 | * # | | : `- \`.;`\ _ /`;.`/ - ` : | | #
20 | * # \ \ `_. \_ __\ /__ _/ .-` / / #
21 | * # =====`-.____`.___ \_____/___.-`___.-'===== #
22 | * # `=---=' #
23 | * # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #
24 | * # #
25 | * # 佛祖保佑 永无BUG #
26 | * # #
27 | */
28 |
29 | package com.jiang.android.resend_sms;
30 |
31 | import android.content.Context;
32 | import android.content.SharedPreferences;
33 |
34 | public class SharePrefUtil {
35 | private static String tag = SharePrefUtil.class.getSimpleName();
36 | private static String SP_NAME = "resend_sms_config";
37 | private static SharedPreferences sp;
38 |
39 |
40 | public static void initSP_NAME(String sp_name) {
41 | SP_NAME = sp_name;
42 | }
43 |
44 | /**
45 | * 保存布尔值
46 | *
47 | * @param context
48 | * @param key
49 | * @param value
50 | */
51 | public static void saveBoolean(Context context, String key, boolean value) {
52 | if (sp == null)
53 | sp = context.getSharedPreferences(SP_NAME, 0);
54 | sp.edit().putBoolean(key, value).commit();
55 | }
56 |
57 | /**
58 | * 保存字符串
59 | *
60 | * @param context
61 | * @param key
62 | * @param value
63 | */
64 | public static void saveString(Context context, String key, String value) {
65 | if (sp == null)
66 | sp = context.getSharedPreferences(SP_NAME, 0);
67 | sp.edit().putString(key, value).commit();
68 |
69 | }
70 |
71 | public static void clear(Context context) {
72 | if (sp == null)
73 | sp = context.getSharedPreferences(SP_NAME, 0);
74 | sp.edit().clear().commit();
75 | }
76 |
77 | public static void removeItem(Context context, String key) {
78 | if (sp == null)
79 | sp = context.getSharedPreferences(SP_NAME, 0);
80 | sp.edit().remove(key).commit();
81 | }
82 |
83 | /**
84 | * 保存long型
85 | *
86 | * @param context
87 | * @param key
88 | * @param value
89 | */
90 | public static void saveLong(Context context, String key, long value) {
91 | if (sp == null)
92 | sp = context.getSharedPreferences(SP_NAME, 0);
93 | sp.edit().putLong(key, value).commit();
94 | }
95 |
96 | /**
97 | * 保存int型
98 | *
99 | * @param context
100 | * @param key
101 | * @param value
102 | */
103 | public static void saveInt(Context context, String key, int value) {
104 | if (sp == null)
105 | sp = context.getSharedPreferences(SP_NAME, 0);
106 | sp.edit().putInt(key, value).commit();
107 | }
108 |
109 | /**
110 | * 保存float型
111 | *
112 | * @param context
113 | * @param key
114 | * @param value
115 | */
116 | public static void saveFloat(Context context, String key, float value) {
117 | if (sp == null)
118 | sp = context.getSharedPreferences(SP_NAME, 0);
119 | sp.edit().putFloat(key, value).commit();
120 | }
121 |
122 | /**
123 | * 获取字符值
124 | *
125 | * @param context
126 | * @param key
127 | * @param defValue
128 | * @return
129 | */
130 | public static String getString(Context context, String key, String defValue) {
131 | if (sp == null)
132 | sp = context.getSharedPreferences(SP_NAME, 0);
133 | return sp.getString(key, defValue);
134 | }
135 |
136 | /**
137 | * 获取int值
138 | *
139 | * @param context
140 | * @param key
141 | * @param defValue
142 | * @return
143 | */
144 | public static int getInt(Context context, String key, int defValue) {
145 | if (sp == null)
146 | sp = context.getSharedPreferences(SP_NAME, 0);
147 | return sp.getInt(key, defValue);
148 | }
149 |
150 | /**
151 | * 获取long值
152 | *
153 | * @param context
154 | * @param key
155 | * @param defValue
156 | * @return
157 | */
158 | public static long getLong(Context context, String key, long defValue) {
159 | if (sp == null)
160 | sp = context.getSharedPreferences(SP_NAME, 0);
161 | return sp.getLong(key, defValue);
162 | }
163 |
164 | /**
165 | * 获取float值
166 | *
167 | * @param context
168 | * @param key
169 | * @param defValue
170 | * @return
171 | */
172 | public static float getFloat(Context context, String key, float defValue) {
173 | if (sp == null)
174 | sp = context.getSharedPreferences(SP_NAME, 0);
175 | return sp.getFloat(key, defValue);
176 | }
177 |
178 | /**
179 | * 获取布尔值
180 | *
181 | * @param context
182 | * @param key
183 | * @param defValue
184 | * @return
185 | */
186 | public static boolean getBoolean(Context context, String key, boolean defValue) {
187 | if (sp == null)
188 | sp = context.getSharedPreferences(SP_NAME, 0);
189 | return sp.getBoolean(key, defValue);
190 | }
191 |
192 | }
193 |
--------------------------------------------------------------------------------