{"id":13643716,"url":"https://github.com/wenmingvs/NotifyUtil","last_synced_at":"2025-04-21T02:31:20.508Z","repository":{"id":113359200,"uuid":"49417277","full_name":"wenmingvs/NotifyUtil","owner":"wenmingvs","description":"通知工具类","archived":false,"fork":false,"pushed_at":"2022-09-09T12:41:33.000Z","size":2703,"stargazers_count":1672,"open_issues_count":14,"forks_count":338,"subscribers_count":50,"default_branch":"master","last_synced_at":"2025-04-08T10:44:28.015Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wenmingvs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2016-01-11T09:58:17.000Z","updated_at":"2025-04-06T05:29:28.000Z","dependencies_parsed_at":"2023-10-21T01:00:41.279Z","dependency_job_id":null,"html_url":"https://github.com/wenmingvs/NotifyUtil","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wenmingvs%2FNotifyUtil","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wenmingvs%2FNotifyUtil/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wenmingvs%2FNotifyUtil/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wenmingvs%2FNotifyUtil/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wenmingvs","download_url":"https://codeload.github.com/wenmingvs/NotifyUtil/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249986052,"owners_count":21356314,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T01:01:51.666Z","updated_at":"2025-04-21T02:31:15.495Z","avatar_url":"https://github.com/wenmingvs.png","language":"Java","readme":"# NotifyDemo  \n\n**高仿淘宝，网易新闻，微信，应用宝，环聊等等热门App的通知视图，并且完通知工具类的封装，提供多达8种最常见的App通知接口,支持Android 5.0悬浮式通知样式**\n\n\n快速下载体验\n-----\n\n[百度网盘](https://github.com/wenmingvs/NotifyUtil/raw/master/sample-debug.apk)\n\n预览图\n-----\n![enter image description here](http://ww3.sinaimg.cn/large/691cc151gw1f0774vsy7xg20dc0k0x6p.gif)\n\n\n用法：\n-----\n\n1. 填充想要展示的内容\n``` java\n        Intent intent = new Intent(mContext, OtherActivity.class);\n        intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);\n        PendingIntent pIntent = PendingIntent.getActivity(mContext,\n                requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT);\n        int smallIcon = R.drawable.tb_bigicon;\n        String ticker = \"您有一条新通知\";\n        String title = \"双十一大优惠！！！\";\n        String content = \"仿真皮肤充气娃娃，女朋友带回家！\";\n```\n  \n2. 实例化工具类，并且调用对应方法即可\n``` java\n NotifyUtil notify1 = new NotifyUtil(mContext, 1);\n notify1.notify_normal_singline(pIntent, smallIcon, ticker, title, content, true, true, false);\n```\n\n\n工具类中的八种通知方法的使用展示\n----- \n1. 淘宝样式：普通类型通知(单行)\n-----\n![enter image description here](http://ww3.sinaimg.cn/large/691cc151gw1f0774vsy7xg20dc0k0x6p.gif)\n\n``` java\n    /**\n     * 高仿淘宝\n     */\n    private void notify_normal_singLine() {\n        //设置想要展示的数据内容\n        Intent intent = new Intent(mContext, OtherActivity.class);\n        intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);\n        PendingIntent pIntent = PendingIntent.getActivity(mContext,\n                requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT);\n        int smallIcon = R.drawable.tb_bigicon;\n        String ticker = \"您有一条新通知\";\n        String title = \"双十一大优惠！！！\";\n        String content = \"仿真皮肤充气娃娃，女朋友带回家！\";\n\n        //实例化工具类，并且调用接口\n        NotifyUtil notify1 = new NotifyUtil(mContext, 1);\n        notify1.notify_normal_singline(pIntent, smallIcon, ticker, title, content, true, true, false);\n        currentNotify = notify1;\n    }\n```\n\n2. 网易新闻样式：普通类型通知(多行)\n-----\n![enter image description here](http://ww2.sinaimg.cn/mw690/691cc151gw1f07752ahgrg20dc0k0u0y.gif)\n``` java\n    /**\n     * 高仿网易新闻\n     */\n    private void notify_normal_moreLine() {\n        //设置想要展示的数据内容\n        Intent intent = new Intent(mContext, OtherActivity.class);\n        intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);\n        PendingIntent pIntent = PendingIntent.getActivity(mContext,\n                requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT);\n        int smallIcon = R.drawable.netease_bigicon;\n        String ticker = \"您有一条新通知\";\n        String title = \"朱立伦请辞国民党主席 副主席黄敏惠暂代党主席\";\n        String content = \"据台湾“中央社”报道，国民党主席朱立伦今天(18日)向中常会报告，为败选请辞党主席一职，他感谢各位中常委的指教包容，也宣布未来党务工作由副主席黄敏惠暂代，完成未来所有补选工作。\";\n        //实例化工具类，并且调用接口\n        NotifyUtil notify2 = new NotifyUtil(mContext, 2);\n        notify2.notify_normail_moreline(pIntent, smallIcon, ticker, title, content, true, true, false);\n        currentNotify = notify2;\n    }\n\n```\n\n3. 微信消息样式： 消息列表通知(含双图标)\n-----\n\n![enter image description here](http://ww4.sinaimg.cn/mw690/691cc151gw1f07757tlbrg20dc0k0hdu.gif)\n\n``` java\n   /**\n     * 收件箱样式\n     */\n    private void notify_mailbox() {\n        //设置想要展示的数据内容\n        Intent intent = new Intent(mContext, OtherActivity.class);\n        intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);\n        PendingIntent pIntent = PendingIntent.getActivity(mContext,\n                requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT);\n        int largeIcon = R.drawable.fbb_largeicon;\n        int smallIcon = R.drawable.wx_smallicon;\n        String ticker = \"您有一条新通知\";\n        String title = \"冰冰\";\n        ArrayList\u003cString\u003e messageList = new ArrayList\u003cString\u003e();\n        messageList.add(\"文明,今晚有空吗？\");\n        messageList.add(\"晚上跟我一起去玩吧?\");\n        messageList.add(\"怎么不回复我？？我生气了！！\");\n        messageList.add(\"我真生气了！！！！！你听见了吗!\");\n        messageList.add(\"文明，别不理我！！！\");\n        String content = \"[\" + messageList.size() + \"条]\" + title + \": \" + messageList.get(0);\n        //实例化工具类，并且调用接口\n        NotifyUtil notify3 = new NotifyUtil(mContext, 3);\n        notify3.notify_mailbox(pIntent, smallIcon, largeIcon, messageList, ticker,\n                title, content, true, true, false);\n        currentNotify = notify3;\n    }\n\n```\n\n\t\n\n4. 系统截图通知样式： 含大图类型通知\n-----\n\n![enter image description here](http://ww2.sinaimg.cn/mw690/691cc151gw1f0775gxs2gg20dc0k0b2c.gif)\n\n``` java\n    /**\n     * 高仿系统截图通知\n     */\n    private void notify_bigPic() {\n        //设置想要展示的数据内容\n        Intent intent = new Intent(mContext, OtherActivity.class);\n        intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);\n        PendingIntent pIntent = PendingIntent.getActivity(mContext,\n                requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT);\n        int smallIcon = R.drawable.xc_smaillicon;\n        int largePic = R.drawable.screenshot;\n        String ticker = \"您有一条新通知\";\n        String title = \"已经抓取屏幕截图\";\n        String content = \"触摸可查看您的屏幕截图\";\n        //实例化工具类，并且调用接口\n        NotifyUtil notify4 = new NotifyUtil(mContext, 4);\n        notify4.notify_bigPic(pIntent, smallIcon, ticker, title, content, largePic, true, true, false);\n        currentNotify = notify4;\n    }\n\n```\n\n5. 应用宝样式： 自定义视图通知\n-----\n\n![enter image description here](http://ww3.sinaimg.cn/mw690/691cc151gw1f0775l59i1g20dc0k0u0x.gif)\n\n``` java\n    /**\n     * 高仿应用宝\n     */\n    private void notify_customview() {\n        //设置想要展示的数据内容\n        Intent intent = new Intent(mContext, OtherActivity.class);\n        intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);\n        PendingIntent pIntent = PendingIntent.getActivity(mContext,\n                requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT);\n        String ticker = \"您有一条新通知\";\n\n        //设置自定义布局中按钮的跳转界面\n        Intent btnIntent = new Intent(mContext, OtherActivity.class);\n        btnIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);\n        //如果是启动activity，那么就用PendingIntent.getActivity，如果是启动服务，那么是getService\n        PendingIntent Pintent = PendingIntent.getActivity(mContext,\n                (int) SystemClock.uptimeMillis(), btnIntent, PendingIntent.FLAG_UPDATE_CURRENT);\n\n        // 自定义布局\n        RemoteViews remoteViews = new RemoteViews(mContext.getPackageName(),\n                R.layout.yyb_notification);\n        remoteViews.setImageViewResource(R.id.image, R.drawable.yybao_bigicon);\n        remoteViews.setTextViewText(R.id.title, \"垃圾安装包太多\");\n        remoteViews.setTextViewText(R.id.text, \"3个无用安装包，清理释放的空间\");\n        remoteViews.setOnClickPendingIntent(R.id.button, Pintent);//定义按钮点击后的动作\n        int smallIcon = R.drawable.yybao_smaillicon;\n        //实例化工具类，并且调用接口\n        NotifyUtil notify5 = new NotifyUtil(mContext, 5);\n        notify5.notify_customview(remoteViews, pIntent, smallIcon, ticker, true, true, false);\n        currentNotify = notify5;\n    }\n```\n\n6. Android系统更新样式： 折叠式双按钮通知\n-----\n![enter image description here](http://ww2.sinaimg.cn/mw690/691cc151gw1f0775pd4dkg20dc0k04qq.gif)\n``` java\n   /**\n     * 高仿Android更新提醒样式\n     */\n    private void notify_buttom() {\n        //设置想要展示的数据内容\n        String ticker = \"您有一条新通知\";\n        int smallIcon = R.drawable.android_bigicon;\n        int lefticon = R.drawable.android_leftbutton;\n        String lefttext = \"以后再说\";\n        Intent leftIntent = new Intent();\n        leftIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);\n        PendingIntent leftPendIntent = PendingIntent.getActivity(mContext,\n                requestCode, leftIntent, PendingIntent.FLAG_UPDATE_CURRENT);\n\n        int righticon = R.drawable.android_rightbutton;\n        String righttext = \"安装\";\n        Intent rightIntent = new Intent(mContext, OtherActivity.class);\n        rightIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);\n        PendingIntent rightPendIntent = PendingIntent.getActivity(mContext,\n                requestCode, rightIntent, PendingIntent.FLAG_UPDATE_CURRENT);\n\n        //实例化工具类，并且调用接口\n        NotifyUtil notify6 = new NotifyUtil(mContext, 6);\n        notify6.notify_button(smallIcon, lefticon, lefttext, leftPendIntent, righticon, righttext, rightPendIntent, ticker, \"系统更新已下载完毕\", \"Android 6.0.1\", true, true, false);\n        currentNotify = notify6;\n    }\n```\n\n7. Android系统下载样式： 进度条通知\n-----\n\n![enter image description here](http://ww2.sinaimg.cn/mw690/691cc151gw1f0775t3kt7g20dc0k0hdt.gif)\n``` java\n\n    /**\n     * 高仿Android系统下载样式\n     */\n    private void notify_progress() {\n        //设置想要展示的数据内容\n        Intent intent = new Intent(mContext, OtherActivity.class);\n        intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);\n        PendingIntent rightPendIntent = PendingIntent.getActivity(mContext,\n                requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT);\n        int smallIcon = R.drawable.android_bigicon;\n        String ticker = \"您有一条新通知\";\n        //实例化工具类，并且调用接口\n        NotifyUtil notify7 = new NotifyUtil(mContext, 7);\n        notify7.notify_progress(rightPendIntent, smallIcon, ticker, \"Android 6.0.1 下载\", \"正在下载中\", true, false, false);\n        currentNotify = notify7;\n    }\n\n```\n\n8. Heads-up 样式： Android 5.0 新特性\n-----\n![enter image description here](http://ww4.sinaimg.cn/mw690/691cc151gw1f0775ybu5lg20dc0k0npe.gif)\n``` java\n/**\n     * Android 5。0 新特性：悬浮式通知\n     */\n    private void notify_headUp() {\n        //设置想要展示的数据内容\n        int smallIcon = R.drawable.hl_smallicon;\n        int largeIcon = R.drawable.fbb_largeicon;\n        String ticker = \"您有一条新通知\";\n        String title = \"范冰冰\";\n        String content = \"文明，今晚在希尔顿酒店2016号房哈\";\n        Intent intent = new Intent(mContext, OtherActivity.class);\n        intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);\n        PendingIntent pendingIntent = PendingIntent.getActivity(mContext,\n                requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT);\n\n\n        int lefticon = R.drawable.hl_message;\n        String lefttext = \"回复\";\n        Intent leftIntent = new Intent();\n        leftIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);\n        PendingIntent leftPendingIntent = PendingIntent.getActivity(mContext,\n                requestCode, leftIntent, PendingIntent.FLAG_UPDATE_CURRENT);\n\n        int righticon = R.drawable.hl_call;\n        String righttext = \"拨打\";\n        Intent rightIntent = new Intent(mContext, OtherActivity.class);\n        rightIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);\n        PendingIntent rightPendingIntent = PendingIntent.getActivity(mContext,\n                requestCode, rightIntent, PendingIntent.FLAG_UPDATE_CURRENT);\n        //实例化工具类，并且调用接口\n        NotifyUtil notify8 = new NotifyUtil(mContext, 8);\n        notify8.notify_HeadUp(pendingIntent, smallIcon, largeIcon, ticker, title, content, lefticon, lefttext, leftPendingIntent, righticon, righttext, rightPendingIntent, true, true, false);\n        currentNotify = notify8;\n    }\n\n```\n\n9. 清空通知\n-----\n``` java\n\nprivate NotifyUtil currentNotify\n\n button1.setOnClickListener(new View.OnClickListener() {\n            @Override\n            public void onClick(View v) {\n                   if (currentNotify != null) {\n                    currentNotify.clear();\n                }\n            }\n        });\n```\n\nGradle 构建\n------\n- 版本\n\t- 最新 Android SDK\n\t- Gradle\n- 环境变量\n\t- ANDROID_HOME\n\t- GRADLE_HOME，同时把bin放入path变量\n\t- Android SDK 安装，都更新到最新\n\t- Android SDK Build-tools更新到最新\n\t- Google Repository更新到最新\n\t- Android Support Repository更新到最新\n\t- Android Support Library更新到最新\n\n\n相信未来\n-----\n当蜘蛛网无情地查封了我的炉台   \n当灰烬的余烟叹息着贫困的悲哀   \n我依然固执地铺平失望的灰烬   \n用美丽的雪花写下：相信未来   \n\n当我的紫葡萄化为深秋的露水   \n当我的鲜花依偎在别人的情怀   \n我依然固执地用凝霜的枯藤   \n在凄凉的大地上写下：相信未来   \n\n我要用手指那涌向天边的排浪  \n我要用手掌那托住太阳的大海  \n摇曳着曙光那枝温暖漂亮的笔杆   \n用孩子的笔体写下：相信未来   \n\n我之所以坚定地相信未来  \n是我相信未来人们的眼睛  \n她有拨开历史风尘的睫毛  \n她有看透岁月篇章的瞳孔  \n\n不管人们对于我们腐烂的皮肉  \n那些迷途的惆怅、失败的苦痛  \n是寄予感动的热泪、深切的同情   \n还是给以轻蔑的微笑、辛辣的嘲讽   \n\n我坚信人们对于我们的脊骨  \n那无数次的探索、迷途、失败和成功   \n一定会给予热情、客观、公正的评定   \n是的，我焦急地等待着他们的评定  \n\n朋友，坚定地相信未来吧  \n相信不屈不挠的努力  \n相信战胜死亡的年轻  \n相信未来、热爱生命  \n\n","funding_links":[],"categories":["通知","Java","App / Demo"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwenmingvs%2FNotifyUtil","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwenmingvs%2FNotifyUtil","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwenmingvs%2FNotifyUtil/lists"}