摘要:基于支付监测app短信监控支付宝微信通知信息, 发送回调金额微信支付宝等过滤信息对接集成的功能实现!
功能描述:该监测APP软件,可以监测任何应用的短信信息内容,及进行自动回调和对接集成。实现由人工手动核对操作,自动处理的转变,实现自动化处理。
方法:监测Android系统在收到短信 支付宝微信通知信息,然后过滤获取其中想要获取到的关键字内容,进行相关数据的上传及回调。
开发工具及编程语言:Eclipse ,JAVA, APP开发。服务后端编程语言:PHP+MYSQL+Http-CURL。
核心源码如下:
//申请设备电源锁
@SuppressLint("InvalidWakeLockTag")
public void acquireWakeLock(Context context) {
if (null == mWakeLock)
{
PowerManager pm = (PowerManager)context.getSystemService(Context.POWER_SERVICE);
mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK|PowerManager.ON_AFTER_RELEASE, "WakeLock");
if (null != mWakeLock)
{
mWakeLock.acquire();
}
}
}
//释放设备电源锁
public void releaseWakeLock() {
if (null != mWakeLock)
{
mWakeLock.release();
mWakeLock = null;
}
}
//心跳进程
public void initAppHeart(){
Log.d(TAG, "开始启动心跳线程");
if (newThread!=null){
return;
}
acquireWakeLock(this);
newThread = new Thread(new Runnable() {
@Override
public void run() {
Log.d(TAG, "心跳线程启动!");
while (true){
SharedPreferences read = getSharedPreferences("vone", MODE_PRIVATE);
host = read.getString("host", "");
key = read.getString("key", "");
uid = read.getString("uid", "");
//这里写入子线程需要做的工作
String t = String.valueOf(new Date().getTime());
String sign = md5(t+key);
OkHttpClient okHttpClient = new OkHttpClient();
Request request = new Request.Builder().url("http://"+host+"/appHeart?t="+t+"&sign="+sign).method("GET",null).build();
//Request request = new Request.Builder().url("http://nfw.bjx-tech.com/appHeart?t="+t+"&sign="+sign+"&uid="+uid).method("GET",null).build();
Call call = okHttpClient.newCall(request);
call.enqueue(new Callback() {
@Override
public void onFailure(Call call, IOException e) {
final String error = e.getMessage();
Handler handlerThree=new Handler(Looper.getMainLooper());
handlerThree.post(new Runnable(){
public void run(){
//Toast.makeText(getApplicationContext() ,"心跳状态错误,请检查配置是否正确!"+error,Toast.LENGTH_LONG).show();
Toast.makeText(getApplicationContext() ,"心跳状态错误,请检查配置是否正确!",Toast.LENGTH_LONG).show();
}
});
}
//请求成功执行的方法
@Override
public void onResponse(Call call, Response response) throws IOException {
Log.d(TAG, "onResponse heard: "+response.body().string());
}
});
try {
Thread.sleep(30*1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
});
newThread.start(); //启动线程
}
import android.os.Build;
public void setOnAsyncResponse(AsyncResponse asyncResponse)
{
this.asyncResponse = asyncResponse;
}
/**
*作者QQ:1918003003. 如有疑问及需求,请添加一起探讨研究!。
* 是否已授权
*
* @return
*/
public class PostTask extends AsyncTask<Map<String, String>, Void, String> {
public AsyncResponse asyncResponse;
public static final MediaType JSON = MediaType.get("application/json; charset=utf-8");
public String TAG="NLService";
OkHttpClient client = new OkHttpClient();
String httppost(String url, String json) throws IOException {
RequestBody body = RequestBody.create(JSON, json);
OkHttpClient client = new OkHttpClient.Builder()
.connectTimeout(10, TimeUnit.SECONDS)//设置连接超时时间
.readTimeout(20, TimeUnit.SECONDS)//设置读取超时时间
.build();
Request.Builder request = new Request.Builder()
.url(url)
.post(body);
try (Response response = client.newCall(request.build()).execute()) {
return response.body().string();
}
OkHttpClient client = new OkHttpClient.Builder()
.connectTimeout(10, TimeUnit.SECONDS)//设置连接超时时间
.readTimeout(20, TimeUnit.SECONDS)//设置读取超时时间
.sslSocketFactory(factory)
.connectionSpecs(specs)
.build();
Request.Builder request = new Request.Builder()
.url(url)
.post(body);
Response response = client.newCall(request.build()).execute();
return response.body().string();
}
catch (KeyManagementException e) {
e.printStackTrace();
return null;
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
return null;
}
}
完成创建检测和回调传送!。
声明Agreement: 本文博主原创文章。禁止使用本程序代码用于任何违法违规业务或项目,造成的任何法律后果自负承担!
作者Author QQ:1918003003. 如有疑问及技术解答需要,欢迎一起探讨研究!。