Skip to content

Repository files navigation

NotifyDemo

[个人博客]

高仿淘宝,网易新闻,微信,应用宝,环聊等等热门App的通知视图,并且完通知工具类的封装,提供多达8种最常见的App通知接口,支持Android 5.0悬浮式通知样式,欢迎大家star我的新的项目

NotifyDemo Android App, require Android 4.0+, GPL v3 License

Download Link

八种通知类型的展示

enter image description here

用法:

  1. 填充想要展示的内容
Intentintent = newIntent(mContext, OtherActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentpIntent = PendingIntent.getActivity(mContext,
requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT);
intsmallIcon = R.drawable.tb_bigicon;
Stringticker = "您有一条新通知";
Stringtitle = "双十一大优惠!!!";
Stringcontent = "仿真皮肤充气娃娃,女朋友带回家!";
  1. 实例化工具类,并且调用对应方法即可
NotifyUtilnotify1 = newNotifyUtil(mContext, 1);
notify1.notify_normal_singline(pIntent, smallIcon, ticker, title, content, true, true, false);

工具类中的八种通知方法的使用展示

  1. 淘宝样式:普通类型通知(单行)

enter image description here

/** * 高仿淘宝 */privatevoidnotify_normal_singLine() {
//设置想要展示的数据内容Intentintent = newIntent(mContext, OtherActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentpIntent = PendingIntent.getActivity(mContext,
requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT);
intsmallIcon = R.drawable.tb_bigicon;
Stringticker = "您有一条新通知";
Stringtitle = "双十一大优惠!!!";
Stringcontent = "仿真皮肤充气娃娃,女朋友带回家!";
//实例化工具类,并且调用接口NotifyUtilnotify1 = newNotifyUtil(mContext, 1);
notify1.notify_normal_singline(pIntent, smallIcon, ticker, title, content, true, true, false);
currentNotify = notify1;
}
  1. 网易新闻样式:普通类型通知(多行)

enter image description here

/** * 高仿网易新闻 */privatevoidnotify_normal_moreLine() {
//设置想要展示的数据内容Intentintent = newIntent(mContext, OtherActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentpIntent = PendingIntent.getActivity(mContext,
requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT);
intsmallIcon = R.drawable.netease_bigicon;
Stringticker = "您有一条新通知";
Stringtitle = "朱立伦请辞国民党主席 副主席黄敏惠暂代党主席";
Stringcontent = "据台湾“中央社”报道,国民党主席朱立伦今天(18日)向中常会报告,为败选请辞党主席一职,他感谢各位中常委的指教包容,也宣布未来党务工作由副主席黄敏惠暂代,完成未来所有补选工作。";
//实例化工具类,并且调用接口NotifyUtilnotify2 = newNotifyUtil(mContext, 2);
notify2.notify_normail_moreline(pIntent, smallIcon, ticker, title, content, true, true, false);
currentNotify = notify2;
}
  1. 微信消息样式: 消息列表通知(含双图标)

enter image description here

/** * 收件箱样式 */privatevoidnotify_mailbox() {
//设置想要展示的数据内容Intentintent = newIntent(mContext, OtherActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentpIntent = PendingIntent.getActivity(mContext,
requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT);
intlargeIcon = R.drawable.fbb_largeicon;
intsmallIcon = R.drawable.wx_smallicon;
Stringticker = "您有一条新通知";
Stringtitle = "冰冰";
ArrayList<String> messageList = newArrayList<String>();
messageList.add("文明,今晚有空吗?");
messageList.add("晚上跟我一起去玩吧?");
messageList.add("怎么不回复我??我生气了!!");
messageList.add("我真生气了!!!!!你听见了吗!");
messageList.add("文明,别不理我!!!");
Stringcontent = "[" + messageList.size() + "条]" + title + ": " + messageList.get(0);
//实例化工具类,并且调用接口NotifyUtilnotify3 = newNotifyUtil(mContext, 3);
notify3.notify_mailbox(pIntent, smallIcon, largeIcon, messageList, ticker,
title, content, true, true, false);
currentNotify = notify3;
}
  1. 系统截图通知样式: 含大图类型通知

enter image description here

/** * 高仿系统截图通知 */privatevoidnotify_bigPic() {
//设置想要展示的数据内容Intentintent = newIntent(mContext, OtherActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentpIntent = PendingIntent.getActivity(mContext,
requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT);
intsmallIcon = R.drawable.xc_smaillicon;
intlargePic = R.drawable.screenshot;
Stringticker = "您有一条新通知";
Stringtitle = "已经抓取屏幕截图";
Stringcontent = "触摸可查看您的屏幕截图";
//实例化工具类,并且调用接口NotifyUtilnotify4 = newNotifyUtil(mContext, 4);
notify4.notify_bigPic(pIntent, smallIcon, ticker, title, content, largePic, true, true, false);
currentNotify = notify4;
}
  1. 应用宝样式: 自定义视图通知

enter image description here

/** * 高仿应用宝 */privatevoidnotify_customview() {
//设置想要展示的数据内容Intentintent = newIntent(mContext, OtherActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentpIntent = PendingIntent.getActivity(mContext,
requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT);
Stringticker = "您有一条新通知";
//设置自定义布局中按钮的跳转界面IntentbtnIntent = newIntent(mContext, OtherActivity.class);
btnIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
//如果是启动activity,那么就用PendingIntent.getActivity,如果是启动服务,那么是getServicePendingIntentPintent = PendingIntent.getActivity(mContext,
(int) SystemClock.uptimeMillis(), btnIntent, PendingIntent.FLAG_UPDATE_CURRENT);
// 自定义布局RemoteViewsremoteViews = newRemoteViews(mContext.getPackageName(),
R.layout.yyb_notification);
remoteViews.setImageViewResource(R.id.image, R.drawable.yybao_bigicon);
remoteViews.setTextViewText(R.id.title, "垃圾安装包太多");
remoteViews.setTextViewText(R.id.text, "3个无用安装包,清理释放的空间");
remoteViews.setOnClickPendingIntent(R.id.button, Pintent);//定义按钮点击后的动作intsmallIcon = R.drawable.yybao_smaillicon;
//实例化工具类,并且调用接口NotifyUtilnotify5 = newNotifyUtil(mContext, 5);
notify5.notify_customview(remoteViews, pIntent, smallIcon, ticker, true, true, false);
currentNotify = notify5;
}
  1. Android系统更新样式: 折叠式双按钮通知

enter image description here

/** * 高仿Android更新提醒样式 */privatevoidnotify_buttom() {
//设置想要展示的数据内容Stringticker = "您有一条新通知";
intsmallIcon = R.drawable.android_bigicon;
intlefticon = R.drawable.android_leftbutton;
Stringlefttext = "以后再说";
IntentleftIntent = newIntent();
leftIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentleftPendIntent = PendingIntent.getActivity(mContext,
requestCode, leftIntent, PendingIntent.FLAG_UPDATE_CURRENT);
intrighticon = R.drawable.android_rightbutton;
Stringrighttext = "安装";
IntentrightIntent = newIntent(mContext, OtherActivity.class);
rightIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentrightPendIntent = PendingIntent.getActivity(mContext,
requestCode, rightIntent, PendingIntent.FLAG_UPDATE_CURRENT);
//实例化工具类,并且调用接口NotifyUtilnotify6 = newNotifyUtil(mContext, 6);
notify6.notify_button(smallIcon, lefticon, lefttext, leftPendIntent, righticon, righttext, rightPendIntent, ticker, "系统更新已下载完毕", "Android 6.0.1", true, true, false);
currentNotify = notify6;
}
  1. Android系统下载样式: 进度条通知

enter image description here

/** * 高仿Android系统下载样式 */privatevoidnotify_progress() {
//设置想要展示的数据内容Intentintent = newIntent(mContext, OtherActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentrightPendIntent = PendingIntent.getActivity(mContext,
requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT);
intsmallIcon = R.drawable.android_bigicon;
Stringticker = "您有一条新通知";
//实例化工具类,并且调用接口NotifyUtilnotify7 = newNotifyUtil(mContext, 7);
notify7.notify_progress(rightPendIntent, smallIcon, ticker, "Android 6.0.1 下载", "正在下载中", true, false, false);
currentNotify = notify7;
}
  1. Heads-up 样式: Android 5.0 新特性

enter image description here

/** * Android 5。0 新特性:悬浮式通知 */privatevoidnotify_headUp() {
//设置想要展示的数据内容intsmallIcon = R.drawable.hl_smallicon;
intlargeIcon = R.drawable.fbb_largeicon;
Stringticker = "您有一条新通知";
Stringtitle = "范冰冰";
Stringcontent = "文明,今晚在希尔顿酒店2016号房哈";
Intentintent = newIntent(mContext, OtherActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentpendingIntent = PendingIntent.getActivity(mContext,
requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT);
intlefticon = R.drawable.hl_message;
Stringlefttext = "回复";
IntentleftIntent = newIntent();
leftIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentleftPendingIntent = PendingIntent.getActivity(mContext,
requestCode, leftIntent, PendingIntent.FLAG_UPDATE_CURRENT);
intrighticon = R.drawable.hl_call;
Stringrighttext = "拨打";
IntentrightIntent = newIntent(mContext, OtherActivity.class);
rightIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentrightPendingIntent = PendingIntent.getActivity(mContext,
requestCode, rightIntent, PendingIntent.FLAG_UPDATE_CURRENT);
//实例化工具类,并且调用接口NotifyUtilnotify8 = newNotifyUtil(mContext, 8);
notify8.notify_HeadUp(pendingIntent, smallIcon, largeIcon, ticker, title, content, lefticon, lefttext, leftPendingIntent, righticon, righttext, rightPendingIntent, true, true, false);
currentNotify = notify8;
}
  1. 清空通知

privateNotifyUtilcurrentNotifybutton1.setOnClickListener(newView.OnClickListener() {
@OverridepublicvoidonClick(Viewv) {
if (currentNotify != null) {
currentNotify.clear();
}
}
});

Gradle 构建

  • 版本
    • 最新 Android SDK
    • Gradle
  • 环境变量
    • ANDROID_HOME
    • GRADLE_HOME,同时把bin放入path变量
    • Android SDK 安装,都更新到最新
    • Android SDK Build-tools更新到最新
    • Google Repository更新到最新
    • Android Support Repository更新到最新
    • Android Support Library更新到最新

相信未来

当蜘蛛网无情地查封了我的炉台
当灰烬的余烟叹息着贫困的悲哀
我依然固执地铺平失望的灰烬
用美丽的雪花写下:相信未来

当我的紫葡萄化为深秋的露水
当我的鲜花依偎在别人的情怀
我依然固执地用凝霜的枯藤
在凄凉的大地上写下:相信未来

我要用手指那涌向天边的排浪
我要用手掌那托住太阳的大海
摇曳着曙光那枝温暖漂亮的笔杆
用孩子的笔体写下:相信未来

我之所以坚定地相信未来
是我相信未来人们的眼睛
她有拨开历史风尘的睫毛
她有看透岁月篇章的瞳孔

不管人们对于我们腐烂的皮肉
那些迷途的惆怅、失败的苦痛
是寄予感动的热泪、深切的同情
还是给以轻蔑的微笑、辛辣的嘲讽

我坚信人们对于我们的脊骨
那无数次的探索、迷途、失败和成功
一定会给予热情、客观、公正的评定
是的,我焦急地等待着他们的评定

朋友,坚定地相信未来吧
相信不屈不挠的努力
相信战胜死亡的年轻
相信未来、热爱生命

About

通知工具类

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { // Add copy buttons to all
 blocks
(function() {
function addCopyButtons() {
document.querySelectorAll('pre code').forEach(function(codeBlock) {
if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;
codeBlock.parentElement.setAttribute('data-copy-added', 'true');
var btn = document.createElement('button');
btn.textContent = 'Copy';
btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';
btn.onmouseover = function() { this.style.opacity = '1'; };
btn.onmouseout = function() { this.style.opacity = '0.7'; };
btn.onclick = function() {
navigator.clipboard.writeText(codeBlock.textContent).then(function() {
btn.textContent = 'Copied!';
setTimeout(function() { btn.textContent = 'Copy'; }, 1500);
});
};
codeBlock.parentElement.style.position = 'relative';
codeBlock.parentElement.appendChild(btn);
});
}
addCopyButtons();
// Re-run on dynamic content
var observer = new MutationObserver(addCopyButtons);
observer.observe(document.body, { childList: true, subtree: true });
})();
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
GitHub - garygogo/NotifyUtil: 通知工具类 · GitHub
Skip to content

Repository files navigation

NotifyDemo

[个人博客]

高仿淘宝,网易新闻,微信,应用宝,环聊等等热门App的通知视图,并且完通知工具类的封装,提供多达8种最常见的App通知接口,支持Android 5.0悬浮式通知样式,欢迎大家star我的新的项目

NotifyDemo Android App, require Android 4.0+, GPL v3 License

Download Link

八种通知类型的展示

enter image description here

用法:

  1. 填充想要展示的内容
Intentintent = newIntent(mContext, OtherActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentpIntent = PendingIntent.getActivity(mContext,
requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT);
intsmallIcon = R.drawable.tb_bigicon;
Stringticker = "您有一条新通知";
Stringtitle = "双十一大优惠!!!";
Stringcontent = "仿真皮肤充气娃娃,女朋友带回家!";
  1. 实例化工具类,并且调用对应方法即可
NotifyUtilnotify1 = newNotifyUtil(mContext, 1);
notify1.notify_normal_singline(pIntent, smallIcon, ticker, title, content, true, true, false);

工具类中的八种通知方法的使用展示

  1. 淘宝样式:普通类型通知(单行)

enter image description here

/** * 高仿淘宝 */privatevoidnotify_normal_singLine() {
//设置想要展示的数据内容Intentintent = newIntent(mContext, OtherActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentpIntent = PendingIntent.getActivity(mContext,
requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT);
intsmallIcon = R.drawable.tb_bigicon;
Stringticker = "您有一条新通知";
Stringtitle = "双十一大优惠!!!";
Stringcontent = "仿真皮肤充气娃娃,女朋友带回家!";
//实例化工具类,并且调用接口NotifyUtilnotify1 = newNotifyUtil(mContext, 1);
notify1.notify_normal_singline(pIntent, smallIcon, ticker, title, content, true, true, false);
currentNotify = notify1;
}
  1. 网易新闻样式:普通类型通知(多行)

enter image description here

/** * 高仿网易新闻 */privatevoidnotify_normal_moreLine() {
//设置想要展示的数据内容Intentintent = newIntent(mContext, OtherActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentpIntent = PendingIntent.getActivity(mContext,
requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT);
intsmallIcon = R.drawable.netease_bigicon;
Stringticker = "您有一条新通知";
Stringtitle = "朱立伦请辞国民党主席 副主席黄敏惠暂代党主席";
Stringcontent = "据台湾“中央社”报道,国民党主席朱立伦今天(18日)向中常会报告,为败选请辞党主席一职,他感谢各位中常委的指教包容,也宣布未来党务工作由副主席黄敏惠暂代,完成未来所有补选工作。";
//实例化工具类,并且调用接口NotifyUtilnotify2 = newNotifyUtil(mContext, 2);
notify2.notify_normail_moreline(pIntent, smallIcon, ticker, title, content, true, true, false);
currentNotify = notify2;
}
  1. 微信消息样式: 消息列表通知(含双图标)

enter image description here

/** * 收件箱样式 */privatevoidnotify_mailbox() {
//设置想要展示的数据内容Intentintent = newIntent(mContext, OtherActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentpIntent = PendingIntent.getActivity(mContext,
requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT);
intlargeIcon = R.drawable.fbb_largeicon;
intsmallIcon = R.drawable.wx_smallicon;
Stringticker = "您有一条新通知";
Stringtitle = "冰冰";
ArrayList<String> messageList = newArrayList<String>();
messageList.add("文明,今晚有空吗?");
messageList.add("晚上跟我一起去玩吧?");
messageList.add("怎么不回复我??我生气了!!");
messageList.add("我真生气了!!!!!你听见了吗!");
messageList.add("文明,别不理我!!!");
Stringcontent = "[" + messageList.size() + "条]" + title + ": " + messageList.get(0);
//实例化工具类,并且调用接口NotifyUtilnotify3 = newNotifyUtil(mContext, 3);
notify3.notify_mailbox(pIntent, smallIcon, largeIcon, messageList, ticker,
title, content, true, true, false);
currentNotify = notify3;
}
  1. 系统截图通知样式: 含大图类型通知

enter image description here

/** * 高仿系统截图通知 */privatevoidnotify_bigPic() {
//设置想要展示的数据内容Intentintent = newIntent(mContext, OtherActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentpIntent = PendingIntent.getActivity(mContext,
requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT);
intsmallIcon = R.drawable.xc_smaillicon;
intlargePic = R.drawable.screenshot;
Stringticker = "您有一条新通知";
Stringtitle = "已经抓取屏幕截图";
Stringcontent = "触摸可查看您的屏幕截图";
//实例化工具类,并且调用接口NotifyUtilnotify4 = newNotifyUtil(mContext, 4);
notify4.notify_bigPic(pIntent, smallIcon, ticker, title, content, largePic, true, true, false);
currentNotify = notify4;
}
  1. 应用宝样式: 自定义视图通知

enter image description here

/** * 高仿应用宝 */privatevoidnotify_customview() {
//设置想要展示的数据内容Intentintent = newIntent(mContext, OtherActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentpIntent = PendingIntent.getActivity(mContext,
requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT);
Stringticker = "您有一条新通知";
//设置自定义布局中按钮的跳转界面IntentbtnIntent = newIntent(mContext, OtherActivity.class);
btnIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
//如果是启动activity,那么就用PendingIntent.getActivity,如果是启动服务,那么是getServicePendingIntentPintent = PendingIntent.getActivity(mContext,
(int) SystemClock.uptimeMillis(), btnIntent, PendingIntent.FLAG_UPDATE_CURRENT);
// 自定义布局RemoteViewsremoteViews = newRemoteViews(mContext.getPackageName(),
R.layout.yyb_notification);
remoteViews.setImageViewResource(R.id.image, R.drawable.yybao_bigicon);
remoteViews.setTextViewText(R.id.title, "垃圾安装包太多");
remoteViews.setTextViewText(R.id.text, "3个无用安装包,清理释放的空间");
remoteViews.setOnClickPendingIntent(R.id.button, Pintent);//定义按钮点击后的动作intsmallIcon = R.drawable.yybao_smaillicon;
//实例化工具类,并且调用接口NotifyUtilnotify5 = newNotifyUtil(mContext, 5);
notify5.notify_customview(remoteViews, pIntent, smallIcon, ticker, true, true, false);
currentNotify = notify5;
}
  1. Android系统更新样式: 折叠式双按钮通知

enter image description here

/** * 高仿Android更新提醒样式 */privatevoidnotify_buttom() {
//设置想要展示的数据内容Stringticker = "您有一条新通知";
intsmallIcon = R.drawable.android_bigicon;
intlefticon = R.drawable.android_leftbutton;
Stringlefttext = "以后再说";
IntentleftIntent = newIntent();
leftIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentleftPendIntent = PendingIntent.getActivity(mContext,
requestCode, leftIntent, PendingIntent.FLAG_UPDATE_CURRENT);
intrighticon = R.drawable.android_rightbutton;
Stringrighttext = "安装";
IntentrightIntent = newIntent(mContext, OtherActivity.class);
rightIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentrightPendIntent = PendingIntent.getActivity(mContext,
requestCode, rightIntent, PendingIntent.FLAG_UPDATE_CURRENT);
//实例化工具类,并且调用接口NotifyUtilnotify6 = newNotifyUtil(mContext, 6);
notify6.notify_button(smallIcon, lefticon, lefttext, leftPendIntent, righticon, righttext, rightPendIntent, ticker, "系统更新已下载完毕", "Android 6.0.1", true, true, false);
currentNotify = notify6;
}
  1. Android系统下载样式: 进度条通知

enter image description here

/** * 高仿Android系统下载样式 */privatevoidnotify_progress() {
//设置想要展示的数据内容Intentintent = newIntent(mContext, OtherActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentrightPendIntent = PendingIntent.getActivity(mContext,
requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT);
intsmallIcon = R.drawable.android_bigicon;
Stringticker = "您有一条新通知";
//实例化工具类,并且调用接口NotifyUtilnotify7 = newNotifyUtil(mContext, 7);
notify7.notify_progress(rightPendIntent, smallIcon, ticker, "Android 6.0.1 下载", "正在下载中", true, false, false);
currentNotify = notify7;
}
  1. Heads-up 样式: Android 5.0 新特性

enter image description here

/** * Android 5。0 新特性:悬浮式通知 */privatevoidnotify_headUp() {
//设置想要展示的数据内容intsmallIcon = R.drawable.hl_smallicon;
intlargeIcon = R.drawable.fbb_largeicon;
Stringticker = "您有一条新通知";
Stringtitle = "范冰冰";
Stringcontent = "文明,今晚在希尔顿酒店2016号房哈";
Intentintent = newIntent(mContext, OtherActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentpendingIntent = PendingIntent.getActivity(mContext,
requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT);
intlefticon = R.drawable.hl_message;
Stringlefttext = "回复";
IntentleftIntent = newIntent();
leftIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentleftPendingIntent = PendingIntent.getActivity(mContext,
requestCode, leftIntent, PendingIntent.FLAG_UPDATE_CURRENT);
intrighticon = R.drawable.hl_call;
Stringrighttext = "拨打";
IntentrightIntent = newIntent(mContext, OtherActivity.class);
rightIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentrightPendingIntent = PendingIntent.getActivity(mContext,
requestCode, rightIntent, PendingIntent.FLAG_UPDATE_CURRENT);
//实例化工具类,并且调用接口NotifyUtilnotify8 = newNotifyUtil(mContext, 8);
notify8.notify_HeadUp(pendingIntent, smallIcon, largeIcon, ticker, title, content, lefticon, lefttext, leftPendingIntent, righticon, righttext, rightPendingIntent, true, true, false);
currentNotify = notify8;
}
  1. 清空通知

privateNotifyUtilcurrentNotifybutton1.setOnClickListener(newView.OnClickListener() {
@OverridepublicvoidonClick(Viewv) {
if (currentNotify != null) {
currentNotify.clear();
}
}
});

Gradle 构建

  • 版本
    • 最新 Android SDK
    • Gradle
  • 环境变量
    • ANDROID_HOME
    • GRADLE_HOME,同时把bin放入path变量
    • Android SDK 安装,都更新到最新
    • Android SDK Build-tools更新到最新
    • Google Repository更新到最新
    • Android Support Repository更新到最新
    • Android Support Library更新到最新

相信未来

当蜘蛛网无情地查封了我的炉台
当灰烬的余烟叹息着贫困的悲哀
我依然固执地铺平失望的灰烬
用美丽的雪花写下:相信未来

当我的紫葡萄化为深秋的露水
当我的鲜花依偎在别人的情怀
我依然固执地用凝霜的枯藤
在凄凉的大地上写下:相信未来

我要用手指那涌向天边的排浪
我要用手掌那托住太阳的大海
摇曳着曙光那枝温暖漂亮的笔杆
用孩子的笔体写下:相信未来

我之所以坚定地相信未来
是我相信未来人们的眼睛
她有拨开历史风尘的睫毛
她有看透岁月篇章的瞳孔

不管人们对于我们腐烂的皮肉
那些迷途的惆怅、失败的苦痛
是寄予感动的热泪、深切的同情
还是给以轻蔑的微笑、辛辣的嘲讽

我坚信人们对于我们的脊骨
那无数次的探索、迷途、失败和成功
一定会给予热情、客观、公正的评定
是的,我焦急地等待着他们的评定

朋友,坚定地相信未来吧
相信不屈不挠的努力
相信战胜死亡的年轻
相信未来、热爱生命

About

通知工具类

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { // Force GitHub README to respect dark mode (function() { var style = document.createElement('style'); style.textContent = ' .markdown-body { color-scheme: dark light; } .markdown-body pre { background: #161b22 !important; } .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; } .markdown-body table th, .markdown-body table td { border-color: #30363d !important; } .markdown-body img { background: #0d1117; } .markdown-body blockquote { border-left-color: #8b949e; } .markdown-body hr { border-color: #30363d; } '; document.head.appendChild(style); })(); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' GitHub - garygogo/NotifyUtil: 通知工具类 · GitHub
Skip to content

Repository files navigation

NotifyDemo

[个人博客]

高仿淘宝,网易新闻,微信,应用宝,环聊等等热门App的通知视图,并且完通知工具类的封装,提供多达8种最常见的App通知接口,支持Android 5.0悬浮式通知样式,欢迎大家star我的新的项目

NotifyDemo Android App, require Android 4.0+, GPL v3 License

Download Link

八种通知类型的展示

enter image description here

用法:

  1. 填充想要展示的内容
Intentintent = newIntent(mContext, OtherActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentpIntent = PendingIntent.getActivity(mContext,
requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT);
intsmallIcon = R.drawable.tb_bigicon;
Stringticker = "您有一条新通知";
Stringtitle = "双十一大优惠!!!";
Stringcontent = "仿真皮肤充气娃娃,女朋友带回家!";
  1. 实例化工具类,并且调用对应方法即可
NotifyUtilnotify1 = newNotifyUtil(mContext, 1);
notify1.notify_normal_singline(pIntent, smallIcon, ticker, title, content, true, true, false);

工具类中的八种通知方法的使用展示

  1. 淘宝样式:普通类型通知(单行)

enter image description here

/** * 高仿淘宝 */privatevoidnotify_normal_singLine() {
//设置想要展示的数据内容Intentintent = newIntent(mContext, OtherActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentpIntent = PendingIntent.getActivity(mContext,
requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT);
intsmallIcon = R.drawable.tb_bigicon;
Stringticker = "您有一条新通知";
Stringtitle = "双十一大优惠!!!";
Stringcontent = "仿真皮肤充气娃娃,女朋友带回家!";
//实例化工具类,并且调用接口NotifyUtilnotify1 = newNotifyUtil(mContext, 1);
notify1.notify_normal_singline(pIntent, smallIcon, ticker, title, content, true, true, false);
currentNotify = notify1;
}
  1. 网易新闻样式:普通类型通知(多行)

enter image description here

/** * 高仿网易新闻 */privatevoidnotify_normal_moreLine() {
//设置想要展示的数据内容Intentintent = newIntent(mContext, OtherActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentpIntent = PendingIntent.getActivity(mContext,
requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT);
intsmallIcon = R.drawable.netease_bigicon;
Stringticker = "您有一条新通知";
Stringtitle = "朱立伦请辞国民党主席 副主席黄敏惠暂代党主席";
Stringcontent = "据台湾“中央社”报道,国民党主席朱立伦今天(18日)向中常会报告,为败选请辞党主席一职,他感谢各位中常委的指教包容,也宣布未来党务工作由副主席黄敏惠暂代,完成未来所有补选工作。";
//实例化工具类,并且调用接口NotifyUtilnotify2 = newNotifyUtil(mContext, 2);
notify2.notify_normail_moreline(pIntent, smallIcon, ticker, title, content, true, true, false);
currentNotify = notify2;
}
  1. 微信消息样式: 消息列表通知(含双图标)

enter image description here

/** * 收件箱样式 */privatevoidnotify_mailbox() {
//设置想要展示的数据内容Intentintent = newIntent(mContext, OtherActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentpIntent = PendingIntent.getActivity(mContext,
requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT);
intlargeIcon = R.drawable.fbb_largeicon;
intsmallIcon = R.drawable.wx_smallicon;
Stringticker = "您有一条新通知";
Stringtitle = "冰冰";
ArrayList<String> messageList = newArrayList<String>();
messageList.add("文明,今晚有空吗?");
messageList.add("晚上跟我一起去玩吧?");
messageList.add("怎么不回复我??我生气了!!");
messageList.add("我真生气了!!!!!你听见了吗!");
messageList.add("文明,别不理我!!!");
Stringcontent = "[" + messageList.size() + "条]" + title + ": " + messageList.get(0);
//实例化工具类,并且调用接口NotifyUtilnotify3 = newNotifyUtil(mContext, 3);
notify3.notify_mailbox(pIntent, smallIcon, largeIcon, messageList, ticker,
title, content, true, true, false);
currentNotify = notify3;
}
  1. 系统截图通知样式: 含大图类型通知

enter image description here

/** * 高仿系统截图通知 */privatevoidnotify_bigPic() {
//设置想要展示的数据内容Intentintent = newIntent(mContext, OtherActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentpIntent = PendingIntent.getActivity(mContext,
requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT);
intsmallIcon = R.drawable.xc_smaillicon;
intlargePic = R.drawable.screenshot;
Stringticker = "您有一条新通知";
Stringtitle = "已经抓取屏幕截图";
Stringcontent = "触摸可查看您的屏幕截图";
//实例化工具类,并且调用接口NotifyUtilnotify4 = newNotifyUtil(mContext, 4);
notify4.notify_bigPic(pIntent, smallIcon, ticker, title, content, largePic, true, true, false);
currentNotify = notify4;
}
  1. 应用宝样式: 自定义视图通知

enter image description here

/** * 高仿应用宝 */privatevoidnotify_customview() {
//设置想要展示的数据内容Intentintent = newIntent(mContext, OtherActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentpIntent = PendingIntent.getActivity(mContext,
requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT);
Stringticker = "您有一条新通知";
//设置自定义布局中按钮的跳转界面IntentbtnIntent = newIntent(mContext, OtherActivity.class);
btnIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
//如果是启动activity,那么就用PendingIntent.getActivity,如果是启动服务,那么是getServicePendingIntentPintent = PendingIntent.getActivity(mContext,
(int) SystemClock.uptimeMillis(), btnIntent, PendingIntent.FLAG_UPDATE_CURRENT);
// 自定义布局RemoteViewsremoteViews = newRemoteViews(mContext.getPackageName(),
R.layout.yyb_notification);
remoteViews.setImageViewResource(R.id.image, R.drawable.yybao_bigicon);
remoteViews.setTextViewText(R.id.title, "垃圾安装包太多");
remoteViews.setTextViewText(R.id.text, "3个无用安装包,清理释放的空间");
remoteViews.setOnClickPendingIntent(R.id.button, Pintent);//定义按钮点击后的动作intsmallIcon = R.drawable.yybao_smaillicon;
//实例化工具类,并且调用接口NotifyUtilnotify5 = newNotifyUtil(mContext, 5);
notify5.notify_customview(remoteViews, pIntent, smallIcon, ticker, true, true, false);
currentNotify = notify5;
}
  1. Android系统更新样式: 折叠式双按钮通知

enter image description here

/** * 高仿Android更新提醒样式 */privatevoidnotify_buttom() {
//设置想要展示的数据内容Stringticker = "您有一条新通知";
intsmallIcon = R.drawable.android_bigicon;
intlefticon = R.drawable.android_leftbutton;
Stringlefttext = "以后再说";
IntentleftIntent = newIntent();
leftIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentleftPendIntent = PendingIntent.getActivity(mContext,
requestCode, leftIntent, PendingIntent.FLAG_UPDATE_CURRENT);
intrighticon = R.drawable.android_rightbutton;
Stringrighttext = "安装";
IntentrightIntent = newIntent(mContext, OtherActivity.class);
rightIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentrightPendIntent = PendingIntent.getActivity(mContext,
requestCode, rightIntent, PendingIntent.FLAG_UPDATE_CURRENT);
//实例化工具类,并且调用接口NotifyUtilnotify6 = newNotifyUtil(mContext, 6);
notify6.notify_button(smallIcon, lefticon, lefttext, leftPendIntent, righticon, righttext, rightPendIntent, ticker, "系统更新已下载完毕", "Android 6.0.1", true, true, false);
currentNotify = notify6;
}
  1. Android系统下载样式: 进度条通知

enter image description here

/** * 高仿Android系统下载样式 */privatevoidnotify_progress() {
//设置想要展示的数据内容Intentintent = newIntent(mContext, OtherActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentrightPendIntent = PendingIntent.getActivity(mContext,
requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT);
intsmallIcon = R.drawable.android_bigicon;
Stringticker = "您有一条新通知";
//实例化工具类,并且调用接口NotifyUtilnotify7 = newNotifyUtil(mContext, 7);
notify7.notify_progress(rightPendIntent, smallIcon, ticker, "Android 6.0.1 下载", "正在下载中", true, false, false);
currentNotify = notify7;
}
  1. Heads-up 样式: Android 5.0 新特性

enter image description here

/** * Android 5。0 新特性:悬浮式通知 */privatevoidnotify_headUp() {
//设置想要展示的数据内容intsmallIcon = R.drawable.hl_smallicon;
intlargeIcon = R.drawable.fbb_largeicon;
Stringticker = "您有一条新通知";
Stringtitle = "范冰冰";
Stringcontent = "文明,今晚在希尔顿酒店2016号房哈";
Intentintent = newIntent(mContext, OtherActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentpendingIntent = PendingIntent.getActivity(mContext,
requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT);
intlefticon = R.drawable.hl_message;
Stringlefttext = "回复";
IntentleftIntent = newIntent();
leftIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentleftPendingIntent = PendingIntent.getActivity(mContext,
requestCode, leftIntent, PendingIntent.FLAG_UPDATE_CURRENT);
intrighticon = R.drawable.hl_call;
Stringrighttext = "拨打";
IntentrightIntent = newIntent(mContext, OtherActivity.class);
rightIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentrightPendingIntent = PendingIntent.getActivity(mContext,
requestCode, rightIntent, PendingIntent.FLAG_UPDATE_CURRENT);
//实例化工具类,并且调用接口NotifyUtilnotify8 = newNotifyUtil(mContext, 8);
notify8.notify_HeadUp(pendingIntent, smallIcon, largeIcon, ticker, title, content, lefticon, lefttext, leftPendingIntent, righticon, righttext, rightPendingIntent, true, true, false);
currentNotify = notify8;
}
  1. 清空通知

privateNotifyUtilcurrentNotifybutton1.setOnClickListener(newView.OnClickListener() {
@OverridepublicvoidonClick(Viewv) {
if (currentNotify != null) {
currentNotify.clear();
}
}
});

Gradle 构建

  • 版本
    • 最新 Android SDK
    • Gradle
  • 环境变量
    • ANDROID_HOME
    • GRADLE_HOME,同时把bin放入path变量
    • Android SDK 安装,都更新到最新
    • Android SDK Build-tools更新到最新
    • Google Repository更新到最新
    • Android Support Repository更新到最新
    • Android Support Library更新到最新

相信未来

当蜘蛛网无情地查封了我的炉台
当灰烬的余烟叹息着贫困的悲哀
我依然固执地铺平失望的灰烬
用美丽的雪花写下:相信未来

当我的紫葡萄化为深秋的露水
当我的鲜花依偎在别人的情怀
我依然固执地用凝霜的枯藤
在凄凉的大地上写下:相信未来

我要用手指那涌向天边的排浪
我要用手掌那托住太阳的大海
摇曳着曙光那枝温暖漂亮的笔杆
用孩子的笔体写下:相信未来

我之所以坚定地相信未来
是我相信未来人们的眼睛
她有拨开历史风尘的睫毛
她有看透岁月篇章的瞳孔

不管人们对于我们腐烂的皮肉
那些迷途的惆怅、失败的苦痛
是寄予感动的热泪、深切的同情
还是给以轻蔑的微笑、辛辣的嘲讽

我坚信人们对于我们的脊骨
那无数次的探索、迷途、失败和成功
一定会给予热情、客观、公正的评定
是的,我焦急地等待着他们的评定

朋友,坚定地相信未来吧
相信不屈不挠的努力
相信战胜死亡的年轻
相信未来、热爱生命

About

通知工具类

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { // Highlight search terms from Google/DuckDuckGo/Bing referrer (function() { var ref = document.referrer; var terms = []; if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) { var url = new URL(ref); var q = url.searchParams.get('q') || url.searchParams.get('p'); if (q) { terms = q.split(/\s+/).filter(function(t) { return t.length > 2; }); } } if (terms.length === 0) return; var style = document.createElement('style'); style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }'; document.head.appendChild(style); function highlight(node) { if (node.nodeType === 3) { // text node var text = node.textContent; var found = false; terms.forEach(function(term) { var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\]\\]/g, '\\') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' GitHub - garygogo/NotifyUtil: 通知工具类 · GitHub
Skip to content

Repository files navigation

NotifyDemo

[个人博客]

高仿淘宝,网易新闻,微信,应用宝,环聊等等热门App的通知视图,并且完通知工具类的封装,提供多达8种最常见的App通知接口,支持Android 5.0悬浮式通知样式,欢迎大家star我的新的项目

NotifyDemo Android App, require Android 4.0+, GPL v3 License

Download Link

八种通知类型的展示

enter image description here

用法:

  1. 填充想要展示的内容
Intentintent = newIntent(mContext, OtherActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentpIntent = PendingIntent.getActivity(mContext,
requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT);
intsmallIcon = R.drawable.tb_bigicon;
Stringticker = "您有一条新通知";
Stringtitle = "双十一大优惠!!!";
Stringcontent = "仿真皮肤充气娃娃,女朋友带回家!";
  1. 实例化工具类,并且调用对应方法即可
NotifyUtilnotify1 = newNotifyUtil(mContext, 1);
notify1.notify_normal_singline(pIntent, smallIcon, ticker, title, content, true, true, false);

工具类中的八种通知方法的使用展示

  1. 淘宝样式:普通类型通知(单行)

enter image description here

/** * 高仿淘宝 */privatevoidnotify_normal_singLine() {
//设置想要展示的数据内容Intentintent = newIntent(mContext, OtherActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentpIntent = PendingIntent.getActivity(mContext,
requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT);
intsmallIcon = R.drawable.tb_bigicon;
Stringticker = "您有一条新通知";
Stringtitle = "双十一大优惠!!!";
Stringcontent = "仿真皮肤充气娃娃,女朋友带回家!";
//实例化工具类,并且调用接口NotifyUtilnotify1 = newNotifyUtil(mContext, 1);
notify1.notify_normal_singline(pIntent, smallIcon, ticker, title, content, true, true, false);
currentNotify = notify1;
}
  1. 网易新闻样式:普通类型通知(多行)

enter image description here

/** * 高仿网易新闻 */privatevoidnotify_normal_moreLine() {
//设置想要展示的数据内容Intentintent = newIntent(mContext, OtherActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentpIntent = PendingIntent.getActivity(mContext,
requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT);
intsmallIcon = R.drawable.netease_bigicon;
Stringticker = "您有一条新通知";
Stringtitle = "朱立伦请辞国民党主席 副主席黄敏惠暂代党主席";
Stringcontent = "据台湾“中央社”报道,国民党主席朱立伦今天(18日)向中常会报告,为败选请辞党主席一职,他感谢各位中常委的指教包容,也宣布未来党务工作由副主席黄敏惠暂代,完成未来所有补选工作。";
//实例化工具类,并且调用接口NotifyUtilnotify2 = newNotifyUtil(mContext, 2);
notify2.notify_normail_moreline(pIntent, smallIcon, ticker, title, content, true, true, false);
currentNotify = notify2;
}
  1. 微信消息样式: 消息列表通知(含双图标)

enter image description here

/** * 收件箱样式 */privatevoidnotify_mailbox() {
//设置想要展示的数据内容Intentintent = newIntent(mContext, OtherActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentpIntent = PendingIntent.getActivity(mContext,
requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT);
intlargeIcon = R.drawable.fbb_largeicon;
intsmallIcon = R.drawable.wx_smallicon;
Stringticker = "您有一条新通知";
Stringtitle = "冰冰";
ArrayList<String> messageList = newArrayList<String>();
messageList.add("文明,今晚有空吗?");
messageList.add("晚上跟我一起去玩吧?");
messageList.add("怎么不回复我??我生气了!!");
messageList.add("我真生气了!!!!!你听见了吗!");
messageList.add("文明,别不理我!!!");
Stringcontent = "[" + messageList.size() + "条]" + title + ": " + messageList.get(0);
//实例化工具类,并且调用接口NotifyUtilnotify3 = newNotifyUtil(mContext, 3);
notify3.notify_mailbox(pIntent, smallIcon, largeIcon, messageList, ticker,
title, content, true, true, false);
currentNotify = notify3;
}
  1. 系统截图通知样式: 含大图类型通知

enter image description here

/** * 高仿系统截图通知 */privatevoidnotify_bigPic() {
//设置想要展示的数据内容Intentintent = newIntent(mContext, OtherActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentpIntent = PendingIntent.getActivity(mContext,
requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT);
intsmallIcon = R.drawable.xc_smaillicon;
intlargePic = R.drawable.screenshot;
Stringticker = "您有一条新通知";
Stringtitle = "已经抓取屏幕截图";
Stringcontent = "触摸可查看您的屏幕截图";
//实例化工具类,并且调用接口NotifyUtilnotify4 = newNotifyUtil(mContext, 4);
notify4.notify_bigPic(pIntent, smallIcon, ticker, title, content, largePic, true, true, false);
currentNotify = notify4;
}
  1. 应用宝样式: 自定义视图通知

enter image description here

/** * 高仿应用宝 */privatevoidnotify_customview() {
//设置想要展示的数据内容Intentintent = newIntent(mContext, OtherActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentpIntent = PendingIntent.getActivity(mContext,
requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT);
Stringticker = "您有一条新通知";
//设置自定义布局中按钮的跳转界面IntentbtnIntent = newIntent(mContext, OtherActivity.class);
btnIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
//如果是启动activity,那么就用PendingIntent.getActivity,如果是启动服务,那么是getServicePendingIntentPintent = PendingIntent.getActivity(mContext,
(int) SystemClock.uptimeMillis(), btnIntent, PendingIntent.FLAG_UPDATE_CURRENT);
// 自定义布局RemoteViewsremoteViews = newRemoteViews(mContext.getPackageName(),
R.layout.yyb_notification);
remoteViews.setImageViewResource(R.id.image, R.drawable.yybao_bigicon);
remoteViews.setTextViewText(R.id.title, "垃圾安装包太多");
remoteViews.setTextViewText(R.id.text, "3个无用安装包,清理释放的空间");
remoteViews.setOnClickPendingIntent(R.id.button, Pintent);//定义按钮点击后的动作intsmallIcon = R.drawable.yybao_smaillicon;
//实例化工具类,并且调用接口NotifyUtilnotify5 = newNotifyUtil(mContext, 5);
notify5.notify_customview(remoteViews, pIntent, smallIcon, ticker, true, true, false);
currentNotify = notify5;
}
  1. Android系统更新样式: 折叠式双按钮通知

enter image description here

/** * 高仿Android更新提醒样式 */privatevoidnotify_buttom() {
//设置想要展示的数据内容Stringticker = "您有一条新通知";
intsmallIcon = R.drawable.android_bigicon;
intlefticon = R.drawable.android_leftbutton;
Stringlefttext = "以后再说";
IntentleftIntent = newIntent();
leftIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentleftPendIntent = PendingIntent.getActivity(mContext,
requestCode, leftIntent, PendingIntent.FLAG_UPDATE_CURRENT);
intrighticon = R.drawable.android_rightbutton;
Stringrighttext = "安装";
IntentrightIntent = newIntent(mContext, OtherActivity.class);
rightIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentrightPendIntent = PendingIntent.getActivity(mContext,
requestCode, rightIntent, PendingIntent.FLAG_UPDATE_CURRENT);
//实例化工具类,并且调用接口NotifyUtilnotify6 = newNotifyUtil(mContext, 6);
notify6.notify_button(smallIcon, lefticon, lefttext, leftPendIntent, righticon, righttext, rightPendIntent, ticker, "系统更新已下载完毕", "Android 6.0.1", true, true, false);
currentNotify = notify6;
}
  1. Android系统下载样式: 进度条通知

enter image description here

/** * 高仿Android系统下载样式 */privatevoidnotify_progress() {
//设置想要展示的数据内容Intentintent = newIntent(mContext, OtherActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentrightPendIntent = PendingIntent.getActivity(mContext,
requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT);
intsmallIcon = R.drawable.android_bigicon;
Stringticker = "您有一条新通知";
//实例化工具类,并且调用接口NotifyUtilnotify7 = newNotifyUtil(mContext, 7);
notify7.notify_progress(rightPendIntent, smallIcon, ticker, "Android 6.0.1 下载", "正在下载中", true, false, false);
currentNotify = notify7;
}
  1. Heads-up 样式: Android 5.0 新特性

enter image description here

/** * Android 5。0 新特性:悬浮式通知 */privatevoidnotify_headUp() {
//设置想要展示的数据内容intsmallIcon = R.drawable.hl_smallicon;
intlargeIcon = R.drawable.fbb_largeicon;
Stringticker = "您有一条新通知";
Stringtitle = "范冰冰";
Stringcontent = "文明,今晚在希尔顿酒店2016号房哈";
Intentintent = newIntent(mContext, OtherActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentpendingIntent = PendingIntent.getActivity(mContext,
requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT);
intlefticon = R.drawable.hl_message;
Stringlefttext = "回复";
IntentleftIntent = newIntent();
leftIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentleftPendingIntent = PendingIntent.getActivity(mContext,
requestCode, leftIntent, PendingIntent.FLAG_UPDATE_CURRENT);
intrighticon = R.drawable.hl_call;
Stringrighttext = "拨打";
IntentrightIntent = newIntent(mContext, OtherActivity.class);
rightIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentrightPendingIntent = PendingIntent.getActivity(mContext,
requestCode, rightIntent, PendingIntent.FLAG_UPDATE_CURRENT);
//实例化工具类,并且调用接口NotifyUtilnotify8 = newNotifyUtil(mContext, 8);
notify8.notify_HeadUp(pendingIntent, smallIcon, largeIcon, ticker, title, content, lefticon, lefttext, leftPendingIntent, righticon, righttext, rightPendingIntent, true, true, false);
currentNotify = notify8;
}
  1. 清空通知

privateNotifyUtilcurrentNotifybutton1.setOnClickListener(newView.OnClickListener() {
@OverridepublicvoidonClick(Viewv) {
if (currentNotify != null) {
currentNotify.clear();
}
}
});

Gradle 构建

  • 版本
    • 最新 Android SDK
    • Gradle
  • 环境变量
    • ANDROID_HOME
    • GRADLE_HOME,同时把bin放入path变量
    • Android SDK 安装,都更新到最新
    • Android SDK Build-tools更新到最新
    • Google Repository更新到最新
    • Android Support Repository更新到最新
    • Android Support Library更新到最新

相信未来

当蜘蛛网无情地查封了我的炉台
当灰烬的余烟叹息着贫困的悲哀
我依然固执地铺平失望的灰烬
用美丽的雪花写下:相信未来

当我的紫葡萄化为深秋的露水
当我的鲜花依偎在别人的情怀
我依然固执地用凝霜的枯藤
在凄凉的大地上写下:相信未来

我要用手指那涌向天边的排浪
我要用手掌那托住太阳的大海
摇曳着曙光那枝温暖漂亮的笔杆
用孩子的笔体写下:相信未来

我之所以坚定地相信未来
是我相信未来人们的眼睛
她有拨开历史风尘的睫毛
她有看透岁月篇章的瞳孔

不管人们对于我们腐烂的皮肉
那些迷途的惆怅、失败的苦痛
是寄予感动的热泪、深切的同情
还是给以轻蔑的微笑、辛辣的嘲讽

我坚信人们对于我们的脊骨
那无数次的探索、迷途、失败和成功
一定会给予热情、客观、公正的评定
是的,我焦急地等待着他们的评定

朋友,坚定地相信未来吧
相信不屈不挠的努力
相信战胜死亡的年轻
相信未来、热爱生命

About

通知工具类

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ' GitHub - garygogo/NotifyUtil: 通知工具类 · GitHub
Skip to content

Repository files navigation

NotifyDemo

[个人博客]

高仿淘宝,网易新闻,微信,应用宝,环聊等等热门App的通知视图,并且完通知工具类的封装,提供多达8种最常见的App通知接口,支持Android 5.0悬浮式通知样式,欢迎大家star我的新的项目

NotifyDemo Android App, require Android 4.0+, GPL v3 License

Download Link

八种通知类型的展示

enter image description here

用法:

  1. 填充想要展示的内容
Intentintent = newIntent(mContext, OtherActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentpIntent = PendingIntent.getActivity(mContext,
requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT);
intsmallIcon = R.drawable.tb_bigicon;
Stringticker = "您有一条新通知";
Stringtitle = "双十一大优惠!!!";
Stringcontent = "仿真皮肤充气娃娃,女朋友带回家!";
  1. 实例化工具类,并且调用对应方法即可
NotifyUtilnotify1 = newNotifyUtil(mContext, 1);
notify1.notify_normal_singline(pIntent, smallIcon, ticker, title, content, true, true, false);

工具类中的八种通知方法的使用展示

  1. 淘宝样式:普通类型通知(单行)

enter image description here

/** * 高仿淘宝 */privatevoidnotify_normal_singLine() {
//设置想要展示的数据内容Intentintent = newIntent(mContext, OtherActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentpIntent = PendingIntent.getActivity(mContext,
requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT);
intsmallIcon = R.drawable.tb_bigicon;
Stringticker = "您有一条新通知";
Stringtitle = "双十一大优惠!!!";
Stringcontent = "仿真皮肤充气娃娃,女朋友带回家!";
//实例化工具类,并且调用接口NotifyUtilnotify1 = newNotifyUtil(mContext, 1);
notify1.notify_normal_singline(pIntent, smallIcon, ticker, title, content, true, true, false);
currentNotify = notify1;
}
  1. 网易新闻样式:普通类型通知(多行)

enter image description here

/** * 高仿网易新闻 */privatevoidnotify_normal_moreLine() {
//设置想要展示的数据内容Intentintent = newIntent(mContext, OtherActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentpIntent = PendingIntent.getActivity(mContext,
requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT);
intsmallIcon = R.drawable.netease_bigicon;
Stringticker = "您有一条新通知";
Stringtitle = "朱立伦请辞国民党主席 副主席黄敏惠暂代党主席";
Stringcontent = "据台湾“中央社”报道,国民党主席朱立伦今天(18日)向中常会报告,为败选请辞党主席一职,他感谢各位中常委的指教包容,也宣布未来党务工作由副主席黄敏惠暂代,完成未来所有补选工作。";
//实例化工具类,并且调用接口NotifyUtilnotify2 = newNotifyUtil(mContext, 2);
notify2.notify_normail_moreline(pIntent, smallIcon, ticker, title, content, true, true, false);
currentNotify = notify2;
}
  1. 微信消息样式: 消息列表通知(含双图标)

enter image description here

/** * 收件箱样式 */privatevoidnotify_mailbox() {
//设置想要展示的数据内容Intentintent = newIntent(mContext, OtherActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentpIntent = PendingIntent.getActivity(mContext,
requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT);
intlargeIcon = R.drawable.fbb_largeicon;
intsmallIcon = R.drawable.wx_smallicon;
Stringticker = "您有一条新通知";
Stringtitle = "冰冰";
ArrayList<String> messageList = newArrayList<String>();
messageList.add("文明,今晚有空吗?");
messageList.add("晚上跟我一起去玩吧?");
messageList.add("怎么不回复我??我生气了!!");
messageList.add("我真生气了!!!!!你听见了吗!");
messageList.add("文明,别不理我!!!");
Stringcontent = "[" + messageList.size() + "条]" + title + ": " + messageList.get(0);
//实例化工具类,并且调用接口NotifyUtilnotify3 = newNotifyUtil(mContext, 3);
notify3.notify_mailbox(pIntent, smallIcon, largeIcon, messageList, ticker,
title, content, true, true, false);
currentNotify = notify3;
}
  1. 系统截图通知样式: 含大图类型通知

enter image description here

/** * 高仿系统截图通知 */privatevoidnotify_bigPic() {
//设置想要展示的数据内容Intentintent = newIntent(mContext, OtherActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentpIntent = PendingIntent.getActivity(mContext,
requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT);
intsmallIcon = R.drawable.xc_smaillicon;
intlargePic = R.drawable.screenshot;
Stringticker = "您有一条新通知";
Stringtitle = "已经抓取屏幕截图";
Stringcontent = "触摸可查看您的屏幕截图";
//实例化工具类,并且调用接口NotifyUtilnotify4 = newNotifyUtil(mContext, 4);
notify4.notify_bigPic(pIntent, smallIcon, ticker, title, content, largePic, true, true, false);
currentNotify = notify4;
}
  1. 应用宝样式: 自定义视图通知

enter image description here

/** * 高仿应用宝 */privatevoidnotify_customview() {
//设置想要展示的数据内容Intentintent = newIntent(mContext, OtherActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentpIntent = PendingIntent.getActivity(mContext,
requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT);
Stringticker = "您有一条新通知";
//设置自定义布局中按钮的跳转界面IntentbtnIntent = newIntent(mContext, OtherActivity.class);
btnIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
//如果是启动activity,那么就用PendingIntent.getActivity,如果是启动服务,那么是getServicePendingIntentPintent = PendingIntent.getActivity(mContext,
(int) SystemClock.uptimeMillis(), btnIntent, PendingIntent.FLAG_UPDATE_CURRENT);
// 自定义布局RemoteViewsremoteViews = newRemoteViews(mContext.getPackageName(),
R.layout.yyb_notification);
remoteViews.setImageViewResource(R.id.image, R.drawable.yybao_bigicon);
remoteViews.setTextViewText(R.id.title, "垃圾安装包太多");
remoteViews.setTextViewText(R.id.text, "3个无用安装包,清理释放的空间");
remoteViews.setOnClickPendingIntent(R.id.button, Pintent);//定义按钮点击后的动作intsmallIcon = R.drawable.yybao_smaillicon;
//实例化工具类,并且调用接口NotifyUtilnotify5 = newNotifyUtil(mContext, 5);
notify5.notify_customview(remoteViews, pIntent, smallIcon, ticker, true, true, false);
currentNotify = notify5;
}
  1. Android系统更新样式: 折叠式双按钮通知

enter image description here

/** * 高仿Android更新提醒样式 */privatevoidnotify_buttom() {
//设置想要展示的数据内容Stringticker = "您有一条新通知";
intsmallIcon = R.drawable.android_bigicon;
intlefticon = R.drawable.android_leftbutton;
Stringlefttext = "以后再说";
IntentleftIntent = newIntent();
leftIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentleftPendIntent = PendingIntent.getActivity(mContext,
requestCode, leftIntent, PendingIntent.FLAG_UPDATE_CURRENT);
intrighticon = R.drawable.android_rightbutton;
Stringrighttext = "安装";
IntentrightIntent = newIntent(mContext, OtherActivity.class);
rightIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentrightPendIntent = PendingIntent.getActivity(mContext,
requestCode, rightIntent, PendingIntent.FLAG_UPDATE_CURRENT);
//实例化工具类,并且调用接口NotifyUtilnotify6 = newNotifyUtil(mContext, 6);
notify6.notify_button(smallIcon, lefticon, lefttext, leftPendIntent, righticon, righttext, rightPendIntent, ticker, "系统更新已下载完毕", "Android 6.0.1", true, true, false);
currentNotify = notify6;
}
  1. Android系统下载样式: 进度条通知

enter image description here

/** * 高仿Android系统下载样式 */privatevoidnotify_progress() {
//设置想要展示的数据内容Intentintent = newIntent(mContext, OtherActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentrightPendIntent = PendingIntent.getActivity(mContext,
requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT);
intsmallIcon = R.drawable.android_bigicon;
Stringticker = "您有一条新通知";
//实例化工具类,并且调用接口NotifyUtilnotify7 = newNotifyUtil(mContext, 7);
notify7.notify_progress(rightPendIntent, smallIcon, ticker, "Android 6.0.1 下载", "正在下载中", true, false, false);
currentNotify = notify7;
}
  1. Heads-up 样式: Android 5.0 新特性

enter image description here

/** * Android 5。0 新特性:悬浮式通知 */privatevoidnotify_headUp() {
//设置想要展示的数据内容intsmallIcon = R.drawable.hl_smallicon;
intlargeIcon = R.drawable.fbb_largeicon;
Stringticker = "您有一条新通知";
Stringtitle = "范冰冰";
Stringcontent = "文明,今晚在希尔顿酒店2016号房哈";
Intentintent = newIntent(mContext, OtherActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentpendingIntent = PendingIntent.getActivity(mContext,
requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT);
intlefticon = R.drawable.hl_message;
Stringlefttext = "回复";
IntentleftIntent = newIntent();
leftIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentleftPendingIntent = PendingIntent.getActivity(mContext,
requestCode, leftIntent, PendingIntent.FLAG_UPDATE_CURRENT);
intrighticon = R.drawable.hl_call;
Stringrighttext = "拨打";
IntentrightIntent = newIntent(mContext, OtherActivity.class);
rightIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentrightPendingIntent = PendingIntent.getActivity(mContext,
requestCode, rightIntent, PendingIntent.FLAG_UPDATE_CURRENT);
//实例化工具类,并且调用接口NotifyUtilnotify8 = newNotifyUtil(mContext, 8);
notify8.notify_HeadUp(pendingIntent, smallIcon, largeIcon, ticker, title, content, lefticon, lefttext, leftPendingIntent, righticon, righttext, rightPendingIntent, true, true, false);
currentNotify = notify8;
}
  1. 清空通知

privateNotifyUtilcurrentNotifybutton1.setOnClickListener(newView.OnClickListener() {
@OverridepublicvoidonClick(Viewv) {
if (currentNotify != null) {
currentNotify.clear();
}
}
});

Gradle 构建

  • 版本
    • 最新 Android SDK
    • Gradle
  • 环境变量
    • ANDROID_HOME
    • GRADLE_HOME,同时把bin放入path变量
    • Android SDK 安装,都更新到最新
    • Android SDK Build-tools更新到最新
    • Google Repository更新到最新
    • Android Support Repository更新到最新
    • Android Support Library更新到最新

相信未来

当蜘蛛网无情地查封了我的炉台
当灰烬的余烟叹息着贫困的悲哀
我依然固执地铺平失望的灰烬
用美丽的雪花写下:相信未来

当我的紫葡萄化为深秋的露水
当我的鲜花依偎在别人的情怀
我依然固执地用凝霜的枯藤
在凄凉的大地上写下:相信未来

我要用手指那涌向天边的排浪
我要用手掌那托住太阳的大海
摇曳着曙光那枝温暖漂亮的笔杆
用孩子的笔体写下:相信未来

我之所以坚定地相信未来
是我相信未来人们的眼睛
她有拨开历史风尘的睫毛
她有看透岁月篇章的瞳孔

不管人们对于我们腐烂的皮肉
那些迷途的惆怅、失败的苦痛
是寄予感动的热泪、深切的同情
还是给以轻蔑的微笑、辛辣的嘲讽

我坚信人们对于我们的脊骨
那无数次的探索、迷途、失败和成功
一定会给予热情、客观、公正的评定
是的,我焦急地等待着他们的评定

朋友,坚定地相信未来吧
相信不屈不挠的努力
相信战胜死亡的年轻
相信未来、热爱生命

About

通知工具类

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' GitHub - garygogo/NotifyUtil: 通知工具类 · GitHub
Skip to content

Repository files navigation

NotifyDemo

[个人博客]

高仿淘宝,网易新闻,微信,应用宝,环聊等等热门App的通知视图,并且完通知工具类的封装,提供多达8种最常见的App通知接口,支持Android 5.0悬浮式通知样式,欢迎大家star我的新的项目

NotifyDemo Android App, require Android 4.0+, GPL v3 License

Download Link

八种通知类型的展示

enter image description here

用法:

  1. 填充想要展示的内容
Intentintent = newIntent(mContext, OtherActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentpIntent = PendingIntent.getActivity(mContext,
requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT);
intsmallIcon = R.drawable.tb_bigicon;
Stringticker = "您有一条新通知";
Stringtitle = "双十一大优惠!!!";
Stringcontent = "仿真皮肤充气娃娃,女朋友带回家!";
  1. 实例化工具类,并且调用对应方法即可
NotifyUtilnotify1 = newNotifyUtil(mContext, 1);
notify1.notify_normal_singline(pIntent, smallIcon, ticker, title, content, true, true, false);

工具类中的八种通知方法的使用展示

  1. 淘宝样式:普通类型通知(单行)

enter image description here

/** * 高仿淘宝 */privatevoidnotify_normal_singLine() {
//设置想要展示的数据内容Intentintent = newIntent(mContext, OtherActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentpIntent = PendingIntent.getActivity(mContext,
requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT);
intsmallIcon = R.drawable.tb_bigicon;
Stringticker = "您有一条新通知";
Stringtitle = "双十一大优惠!!!";
Stringcontent = "仿真皮肤充气娃娃,女朋友带回家!";
//实例化工具类,并且调用接口NotifyUtilnotify1 = newNotifyUtil(mContext, 1);
notify1.notify_normal_singline(pIntent, smallIcon, ticker, title, content, true, true, false);
currentNotify = notify1;
}
  1. 网易新闻样式:普通类型通知(多行)

enter image description here

/** * 高仿网易新闻 */privatevoidnotify_normal_moreLine() {
//设置想要展示的数据内容Intentintent = newIntent(mContext, OtherActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentpIntent = PendingIntent.getActivity(mContext,
requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT);
intsmallIcon = R.drawable.netease_bigicon;
Stringticker = "您有一条新通知";
Stringtitle = "朱立伦请辞国民党主席 副主席黄敏惠暂代党主席";
Stringcontent = "据台湾“中央社”报道,国民党主席朱立伦今天(18日)向中常会报告,为败选请辞党主席一职,他感谢各位中常委的指教包容,也宣布未来党务工作由副主席黄敏惠暂代,完成未来所有补选工作。";
//实例化工具类,并且调用接口NotifyUtilnotify2 = newNotifyUtil(mContext, 2);
notify2.notify_normail_moreline(pIntent, smallIcon, ticker, title, content, true, true, false);
currentNotify = notify2;
}
  1. 微信消息样式: 消息列表通知(含双图标)

enter image description here

/** * 收件箱样式 */privatevoidnotify_mailbox() {
//设置想要展示的数据内容Intentintent = newIntent(mContext, OtherActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentpIntent = PendingIntent.getActivity(mContext,
requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT);
intlargeIcon = R.drawable.fbb_largeicon;
intsmallIcon = R.drawable.wx_smallicon;
Stringticker = "您有一条新通知";
Stringtitle = "冰冰";
ArrayList<String> messageList = newArrayList<String>();
messageList.add("文明,今晚有空吗?");
messageList.add("晚上跟我一起去玩吧?");
messageList.add("怎么不回复我??我生气了!!");
messageList.add("我真生气了!!!!!你听见了吗!");
messageList.add("文明,别不理我!!!");
Stringcontent = "[" + messageList.size() + "条]" + title + ": " + messageList.get(0);
//实例化工具类,并且调用接口NotifyUtilnotify3 = newNotifyUtil(mContext, 3);
notify3.notify_mailbox(pIntent, smallIcon, largeIcon, messageList, ticker,
title, content, true, true, false);
currentNotify = notify3;
}
  1. 系统截图通知样式: 含大图类型通知

enter image description here

/** * 高仿系统截图通知 */privatevoidnotify_bigPic() {
//设置想要展示的数据内容Intentintent = newIntent(mContext, OtherActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentpIntent = PendingIntent.getActivity(mContext,
requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT);
intsmallIcon = R.drawable.xc_smaillicon;
intlargePic = R.drawable.screenshot;
Stringticker = "您有一条新通知";
Stringtitle = "已经抓取屏幕截图";
Stringcontent = "触摸可查看您的屏幕截图";
//实例化工具类,并且调用接口NotifyUtilnotify4 = newNotifyUtil(mContext, 4);
notify4.notify_bigPic(pIntent, smallIcon, ticker, title, content, largePic, true, true, false);
currentNotify = notify4;
}
  1. 应用宝样式: 自定义视图通知

enter image description here

/** * 高仿应用宝 */privatevoidnotify_customview() {
//设置想要展示的数据内容Intentintent = newIntent(mContext, OtherActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentpIntent = PendingIntent.getActivity(mContext,
requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT);
Stringticker = "您有一条新通知";
//设置自定义布局中按钮的跳转界面IntentbtnIntent = newIntent(mContext, OtherActivity.class);
btnIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
//如果是启动activity,那么就用PendingIntent.getActivity,如果是启动服务,那么是getServicePendingIntentPintent = PendingIntent.getActivity(mContext,
(int) SystemClock.uptimeMillis(), btnIntent, PendingIntent.FLAG_UPDATE_CURRENT);
// 自定义布局RemoteViewsremoteViews = newRemoteViews(mContext.getPackageName(),
R.layout.yyb_notification);
remoteViews.setImageViewResource(R.id.image, R.drawable.yybao_bigicon);
remoteViews.setTextViewText(R.id.title, "垃圾安装包太多");
remoteViews.setTextViewText(R.id.text, "3个无用安装包,清理释放的空间");
remoteViews.setOnClickPendingIntent(R.id.button, Pintent);//定义按钮点击后的动作intsmallIcon = R.drawable.yybao_smaillicon;
//实例化工具类,并且调用接口NotifyUtilnotify5 = newNotifyUtil(mContext, 5);
notify5.notify_customview(remoteViews, pIntent, smallIcon, ticker, true, true, false);
currentNotify = notify5;
}
  1. Android系统更新样式: 折叠式双按钮通知

enter image description here

/** * 高仿Android更新提醒样式 */privatevoidnotify_buttom() {
//设置想要展示的数据内容Stringticker = "您有一条新通知";
intsmallIcon = R.drawable.android_bigicon;
intlefticon = R.drawable.android_leftbutton;
Stringlefttext = "以后再说";
IntentleftIntent = newIntent();
leftIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentleftPendIntent = PendingIntent.getActivity(mContext,
requestCode, leftIntent, PendingIntent.FLAG_UPDATE_CURRENT);
intrighticon = R.drawable.android_rightbutton;
Stringrighttext = "安装";
IntentrightIntent = newIntent(mContext, OtherActivity.class);
rightIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentrightPendIntent = PendingIntent.getActivity(mContext,
requestCode, rightIntent, PendingIntent.FLAG_UPDATE_CURRENT);
//实例化工具类,并且调用接口NotifyUtilnotify6 = newNotifyUtil(mContext, 6);
notify6.notify_button(smallIcon, lefticon, lefttext, leftPendIntent, righticon, righttext, rightPendIntent, ticker, "系统更新已下载完毕", "Android 6.0.1", true, true, false);
currentNotify = notify6;
}
  1. Android系统下载样式: 进度条通知

enter image description here

/** * 高仿Android系统下载样式 */privatevoidnotify_progress() {
//设置想要展示的数据内容Intentintent = newIntent(mContext, OtherActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentrightPendIntent = PendingIntent.getActivity(mContext,
requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT);
intsmallIcon = R.drawable.android_bigicon;
Stringticker = "您有一条新通知";
//实例化工具类,并且调用接口NotifyUtilnotify7 = newNotifyUtil(mContext, 7);
notify7.notify_progress(rightPendIntent, smallIcon, ticker, "Android 6.0.1 下载", "正在下载中", true, false, false);
currentNotify = notify7;
}
  1. Heads-up 样式: Android 5.0 新特性

enter image description here

/** * Android 5。0 新特性:悬浮式通知 */privatevoidnotify_headUp() {
//设置想要展示的数据内容intsmallIcon = R.drawable.hl_smallicon;
intlargeIcon = R.drawable.fbb_largeicon;
Stringticker = "您有一条新通知";
Stringtitle = "范冰冰";
Stringcontent = "文明,今晚在希尔顿酒店2016号房哈";
Intentintent = newIntent(mContext, OtherActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentpendingIntent = PendingIntent.getActivity(mContext,
requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT);
intlefticon = R.drawable.hl_message;
Stringlefttext = "回复";
IntentleftIntent = newIntent();
leftIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentleftPendingIntent = PendingIntent.getActivity(mContext,
requestCode, leftIntent, PendingIntent.FLAG_UPDATE_CURRENT);
intrighticon = R.drawable.hl_call;
Stringrighttext = "拨打";
IntentrightIntent = newIntent(mContext, OtherActivity.class);
rightIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentrightPendingIntent = PendingIntent.getActivity(mContext,
requestCode, rightIntent, PendingIntent.FLAG_UPDATE_CURRENT);
//实例化工具类,并且调用接口NotifyUtilnotify8 = newNotifyUtil(mContext, 8);
notify8.notify_HeadUp(pendingIntent, smallIcon, largeIcon, ticker, title, content, lefticon, lefttext, leftPendingIntent, righticon, righttext, rightPendingIntent, true, true, false);
currentNotify = notify8;
}
  1. 清空通知

privateNotifyUtilcurrentNotifybutton1.setOnClickListener(newView.OnClickListener() {
@OverridepublicvoidonClick(Viewv) {
if (currentNotify != null) {
currentNotify.clear();
}
}
});

Gradle 构建

  • 版本
    • 最新 Android SDK
    • Gradle
  • 环境变量
    • ANDROID_HOME
    • GRADLE_HOME,同时把bin放入path变量
    • Android SDK 安装,都更新到最新
    • Android SDK Build-tools更新到最新
    • Google Repository更新到最新
    • Android Support Repository更新到最新
    • Android Support Library更新到最新

相信未来

当蜘蛛网无情地查封了我的炉台
当灰烬的余烟叹息着贫困的悲哀
我依然固执地铺平失望的灰烬
用美丽的雪花写下:相信未来

当我的紫葡萄化为深秋的露水
当我的鲜花依偎在别人的情怀
我依然固执地用凝霜的枯藤
在凄凉的大地上写下:相信未来

我要用手指那涌向天边的排浪
我要用手掌那托住太阳的大海
摇曳着曙光那枝温暖漂亮的笔杆
用孩子的笔体写下:相信未来

我之所以坚定地相信未来
是我相信未来人们的眼睛
她有拨开历史风尘的睫毛
她有看透岁月篇章的瞳孔

不管人们对于我们腐烂的皮肉
那些迷途的惆怅、失败的苦痛
是寄予感动的热泪、深切的同情
还是给以轻蔑的微笑、辛辣的嘲讽

我坚信人们对于我们的脊骨
那无数次的探索、迷途、失败和成功
一定会给予热情、客观、公正的评定
是的,我焦急地等待着他们的评定

朋友,坚定地相信未来吧
相信不屈不挠的努力
相信战胜死亡的年轻
相信未来、热爱生命

About

通知工具类

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' GitHub - garygogo/NotifyUtil: 通知工具类 · GitHub
Skip to content

Repository files navigation

NotifyDemo

[个人博客]

高仿淘宝,网易新闻,微信,应用宝,环聊等等热门App的通知视图,并且完通知工具类的封装,提供多达8种最常见的App通知接口,支持Android 5.0悬浮式通知样式,欢迎大家star我的新的项目

NotifyDemo Android App, require Android 4.0+, GPL v3 License

Download Link

八种通知类型的展示

enter image description here

用法:

  1. 填充想要展示的内容
Intentintent = newIntent(mContext, OtherActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentpIntent = PendingIntent.getActivity(mContext,
requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT);
intsmallIcon = R.drawable.tb_bigicon;
Stringticker = "您有一条新通知";
Stringtitle = "双十一大优惠!!!";
Stringcontent = "仿真皮肤充气娃娃,女朋友带回家!";
  1. 实例化工具类,并且调用对应方法即可
NotifyUtilnotify1 = newNotifyUtil(mContext, 1);
notify1.notify_normal_singline(pIntent, smallIcon, ticker, title, content, true, true, false);

工具类中的八种通知方法的使用展示

  1. 淘宝样式:普通类型通知(单行)

enter image description here

/** * 高仿淘宝 */privatevoidnotify_normal_singLine() {
//设置想要展示的数据内容Intentintent = newIntent(mContext, OtherActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentpIntent = PendingIntent.getActivity(mContext,
requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT);
intsmallIcon = R.drawable.tb_bigicon;
Stringticker = "您有一条新通知";
Stringtitle = "双十一大优惠!!!";
Stringcontent = "仿真皮肤充气娃娃,女朋友带回家!";
//实例化工具类,并且调用接口NotifyUtilnotify1 = newNotifyUtil(mContext, 1);
notify1.notify_normal_singline(pIntent, smallIcon, ticker, title, content, true, true, false);
currentNotify = notify1;
}
  1. 网易新闻样式:普通类型通知(多行)

enter image description here

/** * 高仿网易新闻 */privatevoidnotify_normal_moreLine() {
//设置想要展示的数据内容Intentintent = newIntent(mContext, OtherActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentpIntent = PendingIntent.getActivity(mContext,
requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT);
intsmallIcon = R.drawable.netease_bigicon;
Stringticker = "您有一条新通知";
Stringtitle = "朱立伦请辞国民党主席 副主席黄敏惠暂代党主席";
Stringcontent = "据台湾“中央社”报道,国民党主席朱立伦今天(18日)向中常会报告,为败选请辞党主席一职,他感谢各位中常委的指教包容,也宣布未来党务工作由副主席黄敏惠暂代,完成未来所有补选工作。";
//实例化工具类,并且调用接口NotifyUtilnotify2 = newNotifyUtil(mContext, 2);
notify2.notify_normail_moreline(pIntent, smallIcon, ticker, title, content, true, true, false);
currentNotify = notify2;
}
  1. 微信消息样式: 消息列表通知(含双图标)

enter image description here

/** * 收件箱样式 */privatevoidnotify_mailbox() {
//设置想要展示的数据内容Intentintent = newIntent(mContext, OtherActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentpIntent = PendingIntent.getActivity(mContext,
requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT);
intlargeIcon = R.drawable.fbb_largeicon;
intsmallIcon = R.drawable.wx_smallicon;
Stringticker = "您有一条新通知";
Stringtitle = "冰冰";
ArrayList<String> messageList = newArrayList<String>();
messageList.add("文明,今晚有空吗?");
messageList.add("晚上跟我一起去玩吧?");
messageList.add("怎么不回复我??我生气了!!");
messageList.add("我真生气了!!!!!你听见了吗!");
messageList.add("文明,别不理我!!!");
Stringcontent = "[" + messageList.size() + "条]" + title + ": " + messageList.get(0);
//实例化工具类,并且调用接口NotifyUtilnotify3 = newNotifyUtil(mContext, 3);
notify3.notify_mailbox(pIntent, smallIcon, largeIcon, messageList, ticker,
title, content, true, true, false);
currentNotify = notify3;
}
  1. 系统截图通知样式: 含大图类型通知

enter image description here

/** * 高仿系统截图通知 */privatevoidnotify_bigPic() {
//设置想要展示的数据内容Intentintent = newIntent(mContext, OtherActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentpIntent = PendingIntent.getActivity(mContext,
requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT);
intsmallIcon = R.drawable.xc_smaillicon;
intlargePic = R.drawable.screenshot;
Stringticker = "您有一条新通知";
Stringtitle = "已经抓取屏幕截图";
Stringcontent = "触摸可查看您的屏幕截图";
//实例化工具类,并且调用接口NotifyUtilnotify4 = newNotifyUtil(mContext, 4);
notify4.notify_bigPic(pIntent, smallIcon, ticker, title, content, largePic, true, true, false);
currentNotify = notify4;
}
  1. 应用宝样式: 自定义视图通知

enter image description here

/** * 高仿应用宝 */privatevoidnotify_customview() {
//设置想要展示的数据内容Intentintent = newIntent(mContext, OtherActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentpIntent = PendingIntent.getActivity(mContext,
requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT);
Stringticker = "您有一条新通知";
//设置自定义布局中按钮的跳转界面IntentbtnIntent = newIntent(mContext, OtherActivity.class);
btnIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
//如果是启动activity,那么就用PendingIntent.getActivity,如果是启动服务,那么是getServicePendingIntentPintent = PendingIntent.getActivity(mContext,
(int) SystemClock.uptimeMillis(), btnIntent, PendingIntent.FLAG_UPDATE_CURRENT);
// 自定义布局RemoteViewsremoteViews = newRemoteViews(mContext.getPackageName(),
R.layout.yyb_notification);
remoteViews.setImageViewResource(R.id.image, R.drawable.yybao_bigicon);
remoteViews.setTextViewText(R.id.title, "垃圾安装包太多");
remoteViews.setTextViewText(R.id.text, "3个无用安装包,清理释放的空间");
remoteViews.setOnClickPendingIntent(R.id.button, Pintent);//定义按钮点击后的动作intsmallIcon = R.drawable.yybao_smaillicon;
//实例化工具类,并且调用接口NotifyUtilnotify5 = newNotifyUtil(mContext, 5);
notify5.notify_customview(remoteViews, pIntent, smallIcon, ticker, true, true, false);
currentNotify = notify5;
}
  1. Android系统更新样式: 折叠式双按钮通知

enter image description here

/** * 高仿Android更新提醒样式 */privatevoidnotify_buttom() {
//设置想要展示的数据内容Stringticker = "您有一条新通知";
intsmallIcon = R.drawable.android_bigicon;
intlefticon = R.drawable.android_leftbutton;
Stringlefttext = "以后再说";
IntentleftIntent = newIntent();
leftIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentleftPendIntent = PendingIntent.getActivity(mContext,
requestCode, leftIntent, PendingIntent.FLAG_UPDATE_CURRENT);
intrighticon = R.drawable.android_rightbutton;
Stringrighttext = "安装";
IntentrightIntent = newIntent(mContext, OtherActivity.class);
rightIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentrightPendIntent = PendingIntent.getActivity(mContext,
requestCode, rightIntent, PendingIntent.FLAG_UPDATE_CURRENT);
//实例化工具类,并且调用接口NotifyUtilnotify6 = newNotifyUtil(mContext, 6);
notify6.notify_button(smallIcon, lefticon, lefttext, leftPendIntent, righticon, righttext, rightPendIntent, ticker, "系统更新已下载完毕", "Android 6.0.1", true, true, false);
currentNotify = notify6;
}
  1. Android系统下载样式: 进度条通知

enter image description here

/** * 高仿Android系统下载样式 */privatevoidnotify_progress() {
//设置想要展示的数据内容Intentintent = newIntent(mContext, OtherActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentrightPendIntent = PendingIntent.getActivity(mContext,
requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT);
intsmallIcon = R.drawable.android_bigicon;
Stringticker = "您有一条新通知";
//实例化工具类,并且调用接口NotifyUtilnotify7 = newNotifyUtil(mContext, 7);
notify7.notify_progress(rightPendIntent, smallIcon, ticker, "Android 6.0.1 下载", "正在下载中", true, false, false);
currentNotify = notify7;
}
  1. Heads-up 样式: Android 5.0 新特性

enter image description here

/** * Android 5。0 新特性:悬浮式通知 */privatevoidnotify_headUp() {
//设置想要展示的数据内容intsmallIcon = R.drawable.hl_smallicon;
intlargeIcon = R.drawable.fbb_largeicon;
Stringticker = "您有一条新通知";
Stringtitle = "范冰冰";
Stringcontent = "文明,今晚在希尔顿酒店2016号房哈";
Intentintent = newIntent(mContext, OtherActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentpendingIntent = PendingIntent.getActivity(mContext,
requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT);
intlefticon = R.drawable.hl_message;
Stringlefttext = "回复";
IntentleftIntent = newIntent();
leftIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentleftPendingIntent = PendingIntent.getActivity(mContext,
requestCode, leftIntent, PendingIntent.FLAG_UPDATE_CURRENT);
intrighticon = R.drawable.hl_call;
Stringrighttext = "拨打";
IntentrightIntent = newIntent(mContext, OtherActivity.class);
rightIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentrightPendingIntent = PendingIntent.getActivity(mContext,
requestCode, rightIntent, PendingIntent.FLAG_UPDATE_CURRENT);
//实例化工具类,并且调用接口NotifyUtilnotify8 = newNotifyUtil(mContext, 8);
notify8.notify_HeadUp(pendingIntent, smallIcon, largeIcon, ticker, title, content, lefticon, lefttext, leftPendingIntent, righticon, righttext, rightPendingIntent, true, true, false);
currentNotify = notify8;
}
  1. 清空通知

privateNotifyUtilcurrentNotifybutton1.setOnClickListener(newView.OnClickListener() {
@OverridepublicvoidonClick(Viewv) {
if (currentNotify != null) {
currentNotify.clear();
}
}
});

Gradle 构建

  • 版本
    • 最新 Android SDK
    • Gradle
  • 环境变量
    • ANDROID_HOME
    • GRADLE_HOME,同时把bin放入path变量
    • Android SDK 安装,都更新到最新
    • Android SDK Build-tools更新到最新
    • Google Repository更新到最新
    • Android Support Repository更新到最新
    • Android Support Library更新到最新

相信未来

当蜘蛛网无情地查封了我的炉台
当灰烬的余烟叹息着贫困的悲哀
我依然固执地铺平失望的灰烬
用美丽的雪花写下:相信未来

当我的紫葡萄化为深秋的露水
当我的鲜花依偎在别人的情怀
我依然固执地用凝霜的枯藤
在凄凉的大地上写下:相信未来

我要用手指那涌向天边的排浪
我要用手掌那托住太阳的大海
摇曳着曙光那枝温暖漂亮的笔杆
用孩子的笔体写下:相信未来

我之所以坚定地相信未来
是我相信未来人们的眼睛
她有拨开历史风尘的睫毛
她有看透岁月篇章的瞳孔

不管人们对于我们腐烂的皮肉
那些迷途的惆怅、失败的苦痛
是寄予感动的热泪、深切的同情
还是给以轻蔑的微笑、辛辣的嘲讽

我坚信人们对于我们的脊骨
那无数次的探索、迷途、失败和成功
一定会给予热情、客观、公正的评定
是的,我焦急地等待着他们的评定

朋友,坚定地相信未来吧
相信不屈不挠的努力
相信战胜死亡的年轻
相信未来、热爱生命

About

通知工具类

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { // Universal Dark Mode - works on any site (function() { var enabled = true; function applyDarkMode() { if (!enabled) return; // Create style element if it doesn't exist var style = document.getElementById('universal-dark-mode-style'); if (!style) { style = document.createElement('style'); style.id = 'universal-dark-mode-style'; document.head.appendChild(style); } // Dark mode CSS - inverts colors but preserves images/video style.textContent = ' /* Invert everything except media */ html { filter: invert(1) hue-rotate(180deg) !important; background: #1a1a2e !important; } /* Restore images, videos, iframes, canvas */ img, video, iframe, canvas, svg, picture, [style*="background-image"] { filter: invert(1) hue-rotate(180deg) !important; } /* Preserve specific elements that should not be inverted */ .no-dark-mode, .no-dark-mode *, [data-theme="light"], [data-theme="light"], .ace_editor, .ace_editor *, .CodeMirror, .CodeMirror *, .monaco-editor, .monaco-editor *, .markdown-body pre, .markdown-body pre *, .highlight, .highlight *, pre code, pre code * { filter: none !important; } /* Fix common UI elements */ .modal, .popup, .dropdown-menu, .tooltip, .popover { filter: invert(1) hue-rotate(180deg) !important; background: #2d2d44 !important; border-color: #444 !important; } /* Scrollbars */ ::-webkit-scrollbar { background: #1a1a2e !important; } ::-webkit-scrollbar-thumb { background: #444 !important; } ::-webkit-scrollbar-thumb:hover { background: #555 !important; } /* Selection */ ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; } ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; } '; } function removeDarkMode() { var style = document.getElementById('universal-dark-mode-style'); if (style) style.remove(); } // Toggle with Alt+Shift+D document.addEventListener('keydown', function(e) { if (e.altKey && e.shiftKey && e.key === 'D') { e.preventDefault(); enabled = !enabled; if (enabled) { applyDarkMode(); console.log('[Universal Dark Mode] Enabled'); } else { removeDarkMode(); console.log('[Universal Dark Mode] Disabled'); } } }); // Apply on load applyDarkMode(); // Re-apply on dynamic content var observer = new MutationObserver(function(mutations) { if (enabled && !document.getElementById('universal-dark-mode-style')) { applyDarkMode(); } }); observer.observe(document.head, { childList: true }); console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle'); })(); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })(); GitHub - garygogo/NotifyUtil: 通知工具类 · GitHub
Skip to content

Repository files navigation

NotifyDemo

[个人博客]

高仿淘宝,网易新闻,微信,应用宝,环聊等等热门App的通知视图,并且完通知工具类的封装,提供多达8种最常见的App通知接口,支持Android 5.0悬浮式通知样式,欢迎大家star我的新的项目

NotifyDemo Android App, require Android 4.0+, GPL v3 License

Download Link

八种通知类型的展示

enter image description here

用法:

  1. 填充想要展示的内容
Intentintent = newIntent(mContext, OtherActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentpIntent = PendingIntent.getActivity(mContext,
requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT);
intsmallIcon = R.drawable.tb_bigicon;
Stringticker = "您有一条新通知";
Stringtitle = "双十一大优惠!!!";
Stringcontent = "仿真皮肤充气娃娃,女朋友带回家!";
  1. 实例化工具类,并且调用对应方法即可
NotifyUtilnotify1 = newNotifyUtil(mContext, 1);
notify1.notify_normal_singline(pIntent, smallIcon, ticker, title, content, true, true, false);

工具类中的八种通知方法的使用展示

  1. 淘宝样式:普通类型通知(单行)

enter image description here

/** * 高仿淘宝 */privatevoidnotify_normal_singLine() {
//设置想要展示的数据内容Intentintent = newIntent(mContext, OtherActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentpIntent = PendingIntent.getActivity(mContext,
requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT);
intsmallIcon = R.drawable.tb_bigicon;
Stringticker = "您有一条新通知";
Stringtitle = "双十一大优惠!!!";
Stringcontent = "仿真皮肤充气娃娃,女朋友带回家!";
//实例化工具类,并且调用接口NotifyUtilnotify1 = newNotifyUtil(mContext, 1);
notify1.notify_normal_singline(pIntent, smallIcon, ticker, title, content, true, true, false);
currentNotify = notify1;
}
  1. 网易新闻样式:普通类型通知(多行)

enter image description here

/** * 高仿网易新闻 */privatevoidnotify_normal_moreLine() {
//设置想要展示的数据内容Intentintent = newIntent(mContext, OtherActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentpIntent = PendingIntent.getActivity(mContext,
requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT);
intsmallIcon = R.drawable.netease_bigicon;
Stringticker = "您有一条新通知";
Stringtitle = "朱立伦请辞国民党主席 副主席黄敏惠暂代党主席";
Stringcontent = "据台湾“中央社”报道,国民党主席朱立伦今天(18日)向中常会报告,为败选请辞党主席一职,他感谢各位中常委的指教包容,也宣布未来党务工作由副主席黄敏惠暂代,完成未来所有补选工作。";
//实例化工具类,并且调用接口NotifyUtilnotify2 = newNotifyUtil(mContext, 2);
notify2.notify_normail_moreline(pIntent, smallIcon, ticker, title, content, true, true, false);
currentNotify = notify2;
}
  1. 微信消息样式: 消息列表通知(含双图标)

enter image description here

/** * 收件箱样式 */privatevoidnotify_mailbox() {
//设置想要展示的数据内容Intentintent = newIntent(mContext, OtherActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentpIntent = PendingIntent.getActivity(mContext,
requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT);
intlargeIcon = R.drawable.fbb_largeicon;
intsmallIcon = R.drawable.wx_smallicon;
Stringticker = "您有一条新通知";
Stringtitle = "冰冰";
ArrayList<String> messageList = newArrayList<String>();
messageList.add("文明,今晚有空吗?");
messageList.add("晚上跟我一起去玩吧?");
messageList.add("怎么不回复我??我生气了!!");
messageList.add("我真生气了!!!!!你听见了吗!");
messageList.add("文明,别不理我!!!");
Stringcontent = "[" + messageList.size() + "条]" + title + ": " + messageList.get(0);
//实例化工具类,并且调用接口NotifyUtilnotify3 = newNotifyUtil(mContext, 3);
notify3.notify_mailbox(pIntent, smallIcon, largeIcon, messageList, ticker,
title, content, true, true, false);
currentNotify = notify3;
}
  1. 系统截图通知样式: 含大图类型通知

enter image description here

/** * 高仿系统截图通知 */privatevoidnotify_bigPic() {
//设置想要展示的数据内容Intentintent = newIntent(mContext, OtherActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentpIntent = PendingIntent.getActivity(mContext,
requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT);
intsmallIcon = R.drawable.xc_smaillicon;
intlargePic = R.drawable.screenshot;
Stringticker = "您有一条新通知";
Stringtitle = "已经抓取屏幕截图";
Stringcontent = "触摸可查看您的屏幕截图";
//实例化工具类,并且调用接口NotifyUtilnotify4 = newNotifyUtil(mContext, 4);
notify4.notify_bigPic(pIntent, smallIcon, ticker, title, content, largePic, true, true, false);
currentNotify = notify4;
}
  1. 应用宝样式: 自定义视图通知

enter image description here

/** * 高仿应用宝 */privatevoidnotify_customview() {
//设置想要展示的数据内容Intentintent = newIntent(mContext, OtherActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentpIntent = PendingIntent.getActivity(mContext,
requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT);
Stringticker = "您有一条新通知";
//设置自定义布局中按钮的跳转界面IntentbtnIntent = newIntent(mContext, OtherActivity.class);
btnIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
//如果是启动activity,那么就用PendingIntent.getActivity,如果是启动服务,那么是getServicePendingIntentPintent = PendingIntent.getActivity(mContext,
(int) SystemClock.uptimeMillis(), btnIntent, PendingIntent.FLAG_UPDATE_CURRENT);
// 自定义布局RemoteViewsremoteViews = newRemoteViews(mContext.getPackageName(),
R.layout.yyb_notification);
remoteViews.setImageViewResource(R.id.image, R.drawable.yybao_bigicon);
remoteViews.setTextViewText(R.id.title, "垃圾安装包太多");
remoteViews.setTextViewText(R.id.text, "3个无用安装包,清理释放的空间");
remoteViews.setOnClickPendingIntent(R.id.button, Pintent);//定义按钮点击后的动作intsmallIcon = R.drawable.yybao_smaillicon;
//实例化工具类,并且调用接口NotifyUtilnotify5 = newNotifyUtil(mContext, 5);
notify5.notify_customview(remoteViews, pIntent, smallIcon, ticker, true, true, false);
currentNotify = notify5;
}
  1. Android系统更新样式: 折叠式双按钮通知

enter image description here

/** * 高仿Android更新提醒样式 */privatevoidnotify_buttom() {
//设置想要展示的数据内容Stringticker = "您有一条新通知";
intsmallIcon = R.drawable.android_bigicon;
intlefticon = R.drawable.android_leftbutton;
Stringlefttext = "以后再说";
IntentleftIntent = newIntent();
leftIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentleftPendIntent = PendingIntent.getActivity(mContext,
requestCode, leftIntent, PendingIntent.FLAG_UPDATE_CURRENT);
intrighticon = R.drawable.android_rightbutton;
Stringrighttext = "安装";
IntentrightIntent = newIntent(mContext, OtherActivity.class);
rightIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentrightPendIntent = PendingIntent.getActivity(mContext,
requestCode, rightIntent, PendingIntent.FLAG_UPDATE_CURRENT);
//实例化工具类,并且调用接口NotifyUtilnotify6 = newNotifyUtil(mContext, 6);
notify6.notify_button(smallIcon, lefticon, lefttext, leftPendIntent, righticon, righttext, rightPendIntent, ticker, "系统更新已下载完毕", "Android 6.0.1", true, true, false);
currentNotify = notify6;
}
  1. Android系统下载样式: 进度条通知

enter image description here

/** * 高仿Android系统下载样式 */privatevoidnotify_progress() {
//设置想要展示的数据内容Intentintent = newIntent(mContext, OtherActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentrightPendIntent = PendingIntent.getActivity(mContext,
requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT);
intsmallIcon = R.drawable.android_bigicon;
Stringticker = "您有一条新通知";
//实例化工具类,并且调用接口NotifyUtilnotify7 = newNotifyUtil(mContext, 7);
notify7.notify_progress(rightPendIntent, smallIcon, ticker, "Android 6.0.1 下载", "正在下载中", true, false, false);
currentNotify = notify7;
}
  1. Heads-up 样式: Android 5.0 新特性

enter image description here

/** * Android 5。0 新特性:悬浮式通知 */privatevoidnotify_headUp() {
//设置想要展示的数据内容intsmallIcon = R.drawable.hl_smallicon;
intlargeIcon = R.drawable.fbb_largeicon;
Stringticker = "您有一条新通知";
Stringtitle = "范冰冰";
Stringcontent = "文明,今晚在希尔顿酒店2016号房哈";
Intentintent = newIntent(mContext, OtherActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentpendingIntent = PendingIntent.getActivity(mContext,
requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT);
intlefticon = R.drawable.hl_message;
Stringlefttext = "回复";
IntentleftIntent = newIntent();
leftIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentleftPendingIntent = PendingIntent.getActivity(mContext,
requestCode, leftIntent, PendingIntent.FLAG_UPDATE_CURRENT);
intrighticon = R.drawable.hl_call;
Stringrighttext = "拨打";
IntentrightIntent = newIntent(mContext, OtherActivity.class);
rightIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntentrightPendingIntent = PendingIntent.getActivity(mContext,
requestCode, rightIntent, PendingIntent.FLAG_UPDATE_CURRENT);
//实例化工具类,并且调用接口NotifyUtilnotify8 = newNotifyUtil(mContext, 8);
notify8.notify_HeadUp(pendingIntent, smallIcon, largeIcon, ticker, title, content, lefticon, lefttext, leftPendingIntent, righticon, righttext, rightPendingIntent, true, true, false);
currentNotify = notify8;
}
  1. 清空通知

privateNotifyUtilcurrentNotifybutton1.setOnClickListener(newView.OnClickListener() {
@OverridepublicvoidonClick(Viewv) {
if (currentNotify != null) {
currentNotify.clear();
}
}
});

Gradle 构建

  • 版本
    • 最新 Android SDK
    • Gradle
  • 环境变量
    • ANDROID_HOME
    • GRADLE_HOME,同时把bin放入path变量
    • Android SDK 安装,都更新到最新
    • Android SDK Build-tools更新到最新
    • Google Repository更新到最新
    • Android Support Repository更新到最新
    • Android Support Library更新到最新

相信未来

当蜘蛛网无情地查封了我的炉台
当灰烬的余烟叹息着贫困的悲哀
我依然固执地铺平失望的灰烬
用美丽的雪花写下:相信未来

当我的紫葡萄化为深秋的露水
当我的鲜花依偎在别人的情怀
我依然固执地用凝霜的枯藤
在凄凉的大地上写下:相信未来

我要用手指那涌向天边的排浪
我要用手掌那托住太阳的大海
摇曳着曙光那枝温暖漂亮的笔杆
用孩子的笔体写下:相信未来

我之所以坚定地相信未来
是我相信未来人们的眼睛
她有拨开历史风尘的睫毛
她有看透岁月篇章的瞳孔

不管人们对于我们腐烂的皮肉
那些迷途的惆怅、失败的苦痛
是寄予感动的热泪、深切的同情
还是给以轻蔑的微笑、辛辣的嘲讽

我坚信人们对于我们的脊骨
那无数次的探索、迷途、失败和成功
一定会给予热情、客观、公正的评定
是的,我焦急地等待着他们的评定

朋友,坚定地相信未来吧
相信不屈不挠的努力
相信战胜死亡的年轻
相信未来、热爱生命

About

通知工具类

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages