diff --git a/README.md b/README.md index 0564045..057637d 100644 --- a/README.md +++ b/README.md @@ -72,6 +72,9 @@ V免签为完全开源项目,开源项目意味着作者没有任何收入来 + 微信店员收款推送通知 ## 更新记录 + + v1.6.1(2019.05.17) + + 修复微信无法正常回调的问题 + + v1.6(2019.05.16) + 启用新方式监听到账通知,理论支持更多设备! diff --git a/app/app-release.apk b/app/app-release.apk index 73b63e6..1537709 100644 Binary files a/app/app-release.apk and b/app/app-release.apk differ diff --git a/app/src/main/java/com/vone/vmq/MainActivity.java b/app/src/main/java/com/vone/vmq/MainActivity.java index 38f1961..126fae2 100644 --- a/app/src/main/java/com/vone/vmq/MainActivity.java +++ b/app/src/main/java/com/vone/vmq/MainActivity.java @@ -3,6 +3,7 @@ import android.Manifest; import android.app.AlertDialog; import android.app.Notification; +import android.app.NotificationChannel; import android.app.NotificationManager; import android.content.ActivityNotFoundException; import android.content.ComponentName; @@ -11,13 +12,14 @@ import android.content.Intent; import android.content.SharedPreferences; import android.content.pm.PackageManager; +import android.graphics.Color; import android.media.RingtoneManager; +import android.os.Build; import android.os.Bundle; import android.os.Looper; import android.provider.Settings; import android.support.annotation.NonNull; import android.support.v4.app.ActivityCompat; -import android.support.v4.app.NotificationCompat; import android.support.v4.app.NotificationManagerCompat; import android.support.v7.app.AppCompatActivity; import android.text.TextUtils; @@ -327,28 +329,49 @@ public void checkPush(View v){ // return; // } - - Notification mNotification; NotificationManager mNotificationManager; - mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); - - mNotification = new NotificationCompat.Builder(this) - // 设置小图标 - .setSmallIcon(R.mipmap.ic_launcher) - .setTicker("这是一条测试推送信息,如果程序正常,则会提示监听权限正常") - // 设置标题 - .setContentTitle("V免签测试推送") - // 设置内容 - .setContentText("这是一条测试推送信息,如果程序正常,则会提示监听权限正常") - // 设置Notification提示铃声为系统默认铃声 - .setSound( - RingtoneManager.getActualDefaultRingtoneUri( - getBaseContext(), - RingtoneManager.TYPE_NOTIFICATION)) - - // 点击Notification的时候自动移除 - .build(); + mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); + + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + //ChannelId为"1",ChannelName为"Channel1" + NotificationChannel channel = new NotificationChannel("1", + "Channel1", NotificationManager.IMPORTANCE_DEFAULT); + channel.enableLights(true); //是否在桌面icon右上角展示小红点 + channel.setLightColor(Color.GREEN); //小红点颜色 + channel.setShowBadge(true); //是否在久按桌面图标时显示此渠道的通知 + mNotificationManager.createNotificationChannel(channel); + + Notification.Builder builder = new Notification.Builder(this,"1"); //与channelId对应 + + mNotification = builder + // 设置小图标 + .setSmallIcon(R.mipmap.ic_launcher) + .setTicker("这是一条测试推送信息,如果程序正常,则会提示监听权限正常") + // 设置标题 + .setContentTitle("V免签测试推送") + // 设置内容 + .setContentText("这是一条测试推送信息,如果程序正常,则会提示监听权限正常") + .build(); + }else{ + mNotification = new Notification.Builder(MainActivity.this) + // 设置小图标 + .setSmallIcon(R.mipmap.ic_launcher) + .setTicker("这是一条测试推送信息,如果程序正常,则会提示监听权限正常") + // 设置标题 + .setContentTitle("V免签测试推送") + // 设置内容 + .setContentText("这是一条测试推送信息,如果程序正常,则会提示监听权限正常") + + // 设置Notification提示铃声为系统默认铃声 + .setSound( + RingtoneManager.getActualDefaultRingtoneUri( + getBaseContext(), + RingtoneManager.TYPE_NOTIFICATION)) + + .build(); + } //Toast.makeText(MainActivity.this, "已推送信息,如果权限,那么将会有下一条提示!", Toast.LENGTH_SHORT).show(); diff --git a/app/src/main/java/com/vone/vmq/NeNotificationService2.java b/app/src/main/java/com/vone/vmq/NeNotificationService2.java index 4e6e2f6..9dc8305 100644 --- a/app/src/main/java/com/vone/vmq/NeNotificationService2.java +++ b/app/src/main/java/com/vone/vmq/NeNotificationService2.java @@ -85,9 +85,13 @@ public void onNotificationPosted(StatusBarNotification sbn) { //微信支付: 微信支付收款0.01元(朋友到店) String[] tmp = text.split(":"); if (tmp.length==2){ - if (tmp[0].equals("微信支付") || tmp[0].equals("微信收款助手") ){ + if (tmp[0].equals("微信支付") || tmp[0].equals("微信收款助手") || tmp[0].equals("微信收款商业版")){ if (text.indexOf("微信支付收款")!=-1){ String money = getSubString(text,"微信支付收款","元"); + if (money.indexOf("支付")!=-1){ + money = getSubString(money+"元","微信支付收款","元"); + } + Log.d(TAG, "onAccessibilityEvent: 匹配成功: 微信 到账 "+money); appPush(1,Double.valueOf(money)); }else if (text.indexOf("店员消息")!=-1){