1. 程式人生 > >基於notification服務支付寶微信個人網站收款監控 原始碼下載

基於notification服務支付寶微信個人網站收款監控 原始碼下載

根據notification服務監控手機通知,收到收款金額再通過https反饋給伺服器,需要開通手機通知讀取許可權,有引導客戶開通許可權.同時加入無聲播放音訊,永久守護程序不被系統關掉,穩定性比通過xposed框架hook版的穩定多了,xposed框架的自動生成收款二維碼的我已經開發出來了,待穩定新解決好了馬上分享給大家.

package com.sytapi.activity;
import android.content.SharedPreferences;
import android.service.notification.NotificationListenerService;
import android.service.notification.StatusBarNotification;
import android.util.Log;
import android.widget.Toast;
import java.util.regex.Pattern;
import java.util.regex.Matcher;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;

public class NLService extends NotificationListenerService {


    private String tzlr;
    private String istype;
    private String price;
    private String uid;
    private String Token ;
    public void onNotificationPosted(StatusBarNotification sbn) {

        tzlr = sbn.getNotification().tickerText.toString();
        Log.i("結果ID:", + sbn.getId() + "\t" + tzlr  + "\t" + sbn.getPackageName()+"USERID:" +sbn.getUserId()+"Tag:" +sbn.getTag());
        // Toast.makeText(this, tzlr , Toast.LENGTH_LONG).show();

        if(tzlr.contains("微信支付收款")||tzlr.contains("掃碼向你付款"))


        {

            if(tzlr.contains("微信"))
            {
                istype="2";
                Pattern pattern = Pattern.compile("支付收款(.*?)元");
                Matcher matcher = pattern.matcher(tzlr);
                while (matcher.find()) {
                    // System.out.println(m.group(1));
                    price=  matcher.group(1);
                }


            }
            else
            {   istype="1";

                Pattern pattern = Pattern.compile("向你付款(.*?)元");
                Matcher matcher = pattern.matcher(tzlr);
                while (matcher.find()) {
                    // System.out.println(m.group(1));
                    price=  matcher.group(1);
                }


            }
            SharedPreferences userSettings = getSharedPreferences("drxx", 0);
            uid = userSettings.getString("uid","none");
            Token = userSettings.getString("Token","none");
            //http訪問
            new Thread(new Runnable() {
                @Override


                public void run() {
                    try {
                        tzlr = java.net.URLEncoder.encode(tzlr);
                        URL url = new URL("http://********.com/api/sjtz.aspx?uid="+uid+"&Token="+Token +"&istype="+istype+"&price="+price+"&log=" + tzlr);

                        URLConnection rulConnection = url.openConnection();
                        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
                        connection.setRequestMethod("GET");

                        connection.connect();
                        int responseCode = connection.getResponseCode();

                    } catch (Exception e) {

                    }
                }
            }).start();
        }
        //http訪問END




    }
}