|
@@ -1,9 +1,14 @@
|
|
|
package com.sheep.gamegroup.util;
|
|
package com.sheep.gamegroup.util;
|
|
|
|
|
|
|
|
import android.app.Activity;
|
|
import android.app.Activity;
|
|
|
|
|
+import android.app.Notification;
|
|
|
|
|
+import android.app.NotificationChannel;
|
|
|
|
|
+import android.app.NotificationManager;
|
|
|
import android.content.DialogInterface;
|
|
import android.content.DialogInterface;
|
|
|
import android.content.Intent;
|
|
import android.content.Intent;
|
|
|
|
|
+import android.os.Build;
|
|
|
import android.os.Bundle;
|
|
import android.os.Bundle;
|
|
|
|
|
+import android.support.v4.app.NotificationCompat;
|
|
|
import android.support.v4.app.NotificationManagerCompat;
|
|
import android.support.v4.app.NotificationManagerCompat;
|
|
|
import android.support.v7.app.AlertDialog;
|
|
import android.support.v7.app.AlertDialog;
|
|
|
import android.text.TextUtils;
|
|
import android.text.TextUtils;
|
|
@@ -59,6 +64,7 @@ import rx.android.schedulers.AndroidSchedulers;
|
|
|
import rx.functions.Action1;
|
|
import rx.functions.Action1;
|
|
|
import rx.schedulers.Schedulers;
|
|
import rx.schedulers.Schedulers;
|
|
|
|
|
|
|
|
|
|
+import static android.content.Context.NOTIFICATION_SERVICE;
|
|
|
import static com.sheep.gamegroup.util.CommonUtil.LONG_MAO_APP_PACKAGE_NAME;
|
|
import static com.sheep.gamegroup.util.CommonUtil.LONG_MAO_APP_PACKAGE_NAME;
|
|
|
import static com.sheep.gamegroup.util.CommonUtil.LONG_MAO_APP_URI;
|
|
import static com.sheep.gamegroup.util.CommonUtil.LONG_MAO_APP_URI;
|
|
|
|
|
|
|
@@ -217,7 +223,8 @@ public class TestUtil {
|
|
|
*/
|
|
*/
|
|
|
public static void test(final Activity activity) {
|
|
public static void test(final Activity activity) {
|
|
|
final String[] items = {"复制token","复制打点数据","从jenkins下载小绵羊安装包","龙猫竞猜","龙猫竞猜-scheme",
|
|
final String[] items = {"复制token","复制打点数据","从jenkins下载小绵羊安装包","龙猫竞猜","龙猫竞猜-scheme",
|
|
|
- "测试自定义通知栏","测试自定义通知栏2","开启通知栏权限","通知栏权限1","通知栏权限2","通知栏权限8.0","测试支付","测试内部h5", "测试外部h5",
|
|
|
|
|
|
|
+ "测试通知栏", "测试自定义通知栏","测试自定义通知栏2",
|
|
|
|
|
+ "开启通知栏权限","通知栏权限1","通知栏权限2","通知栏权限8.0","测试支付","测试内部h5", "测试外部h5",
|
|
|
"会长推广游戏","移动积分兑换","审核中心","检查正版","crc32","loading","progress","查看截图",
|
|
"会长推广游戏","移动积分兑换","审核中心","检查正版","crc32","loading","progress","查看截图",
|
|
|
"复制IMEI","小米游戏","测试可用金额","测试定位信息","测试apk的渠道","幂动科技","游戏搜索",
|
|
"复制IMEI","小米游戏","测试可用金额","测试定位信息","测试apk的渠道","幂动科技","游戏搜索",
|
|
|
"游戏帐号","游戏代充","尝试开启第三方应用使用情况","测试代理页面","第三方应用使用情况",
|
|
"游戏帐号","游戏代充","尝试开启第三方应用使用情况","测试代理页面","第三方应用使用情况",
|
|
@@ -231,6 +238,9 @@ public class TestUtil {
|
|
|
@Override
|
|
@Override
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
switch (items[which]) {
|
|
switch (items[which]) {
|
|
|
|
|
+ case "测试通知栏":
|
|
|
|
|
+ testNotification(activity);
|
|
|
|
|
+ break;
|
|
|
case "测试自定义通知栏":
|
|
case "测试自定义通知栏":
|
|
|
Intent bdIntent = new Intent();
|
|
Intent bdIntent = new Intent();
|
|
|
bdIntent.setAction(JPushInterface.ACTION_MESSAGE_RECEIVED);
|
|
bdIntent.setAction(JPushInterface.ACTION_MESSAGE_RECEIVED);
|
|
@@ -496,6 +506,31 @@ public class TestUtil {
|
|
|
}).create();
|
|
}).create();
|
|
|
dialog.show();
|
|
dialog.show();
|
|
|
}
|
|
}
|
|
|
|
|
+ //测试直接显示通知栏
|
|
|
|
|
+ private static void testNotification(Activity activity) {
|
|
|
|
|
+ String id = "my_channel_01";
|
|
|
|
|
+ String name = activity.getString(R.string.app_name);
|
|
|
|
|
+ NotificationManager notificationManager = (NotificationManager) activity.getSystemService(NOTIFICATION_SERVICE);
|
|
|
|
|
+ if(notificationManager != null) {
|
|
|
|
|
+ Notification notification;
|
|
|
|
|
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
|
|
|
+ NotificationChannel mChannel = new NotificationChannel(id, name, NotificationManager.IMPORTANCE_HIGH);
|
|
|
|
|
+ notificationManager.createNotificationChannel(mChannel);
|
|
|
|
|
+ notification = new NotificationCompat.Builder(activity, id)
|
|
|
|
|
+ .setContentTitle("5 new messages")
|
|
|
|
|
+ .setContentText("hahaha")
|
|
|
|
|
+ .setSmallIcon(R.mipmap.ic_launcher).build();
|
|
|
|
|
+ } else {
|
|
|
|
|
+ NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(activity, id)
|
|
|
|
|
+ .setContentTitle("5 new messages")
|
|
|
|
|
+ .setContentText("hahaha")
|
|
|
|
|
+ .setSmallIcon(R.mipmap.ic_launcher)
|
|
|
|
|
+ .setOngoing(true);
|
|
|
|
|
+ notification = notificationBuilder.build();
|
|
|
|
|
+ }
|
|
|
|
|
+ notificationManager.notify(111123, notification);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
|
|
|
private static void copyUrl(final String name) {
|
|
private static void copyUrl(final String name) {
|