{"id":13643724,"url":"https://github.com/hss01248/NotifyUtil","last_synced_at":"2025-04-21T02:31:23.771Z","repository":{"id":90562193,"uuid":"81775532","full_name":"hss01248/NotifyUtil","owner":"hss01248","description":"a better and more compatible api for android notification","archived":false,"fork":false,"pushed_at":"2022-07-06T11:58:21.000Z","size":407,"stargazers_count":282,"open_issues_count":3,"forks_count":54,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-11-09T15:43:25.779Z","etag":null,"topics":["notification","notification-android","notification-api"],"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/hss01248.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,"roadmap":null,"authors":null}},"created_at":"2017-02-13T02:17:37.000Z","updated_at":"2024-07-13T06:40:43.000Z","dependencies_parsed_at":"2023-07-09T03:31:04.215Z","dependency_job_id":null,"html_url":"https://github.com/hss01248/NotifyUtil","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hss01248%2FNotifyUtil","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hss01248%2FNotifyUtil/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hss01248%2FNotifyUtil/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hss01248%2FNotifyUtil/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hss01248","download_url":"https://codeload.github.com/hss01248/NotifyUtil/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249986062,"owners_count":21356316,"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":["notification","notification-android","notification-api"],"created_at":"2024-08-02T01:01:51.785Z","updated_at":"2025-04-21T02:31:18.761Z","avatar_url":"https://github.com/hss01248.png","language":"Java","readme":"# NotifyUtil\n\nnotification工具类,最简化api\n\n# 示例图\n\n\n\n ![simple-bigpic](image/simple-bigpic.jpg)\n\n\n\n ![progress](image/progress.jpg)\n\n\n\n ![bigtext](image/bigtext.jpg)\n\n\n\n ![mailbox](image/mailbox.jpg)\n\n\n\n ![headup](image/headup.jpg)\n\n# API\n\n## Application里的初始化\n\n```\npublic static void init(Context appContext)\n```\n\n\n\n## 第一步:\n\n```\nbuildSimple(int id,int icon,CharSequence contentTitle ,CharSequence contentText,PendingIntent contentIntent)\n  \nbuildProgress(int id,int icon,CharSequence contentTitle,int progress,int max,String format)\n//format参考: 百分比模式: 下载进度:%d%%, 两数据模式: 下载进度:%d/%d\n \n buildBigPic(int id,int icon,CharSequence contentTitle,CharSequence contentText,CharSequence summaryText)\n \n buildBigText(int id,int icon,CharSequence contentTitle,CharSequence contentText)\n \n buildMailBox(int id,int icon,CharSequence contentTitle)\n \n// buildMedia(int id,int icon,CharSequence contentTitle,CharSequence contentText)//todo \n  \n```\n\n## 第二步:其他可选设置\n\n默认情况下:\n\n只有呼吸灯提示\n\n\n\n```\n设置三类intent:\n\nsetContentIntent(PendingIntent contentIntent)\nsetDeleteIntent(PendingIntent deleteIntent)\nsetFullScreenIntent(PendingIntent fullscreenIntent)\n\n添加按钮:\naddBtn(int icon,CharSequence text,PendingIntent pendingIntent)\n开启head-up模式\nsetHeadup()\n//提示语,默认为\"您有新的消息\"\nsetTicker(CharSequence ticker)\n//大小图标\nsetSamllIcon(int smallIcon)\nsetBigIcon(int bigIcon)\n//优先级,默认为default\nsetPriority(int priority)\n//设置成为不可删除\nsetOnGoing()\n//提示模式:默认情况下只有呼吸灯提示\nsetAction(boolean sound, boolean vibrate, boolean lights)\n//设置为前台服务的notification\nsetForgroundService() \n//锁屏显示的控制(默认不显示)\nsetLockScreenVisiablity(int lockScreenVisiablity)\n  VISIBILITY_PRIVATE : 显示基本信息，如通知的图标，但隐藏通知的全部内容 \n  VISIBILITY_PUBLIC : 显示通知的全部内容 \n  VISIBILITY_SECRET : 不显示任何内容，包括图标\n```\n\n## 第三步\n\n```\n.show()\n```\n\n\n\n ## 取消\n\n```\ncancel(int id)\ncancelAll()\n```\n\n# 使用\n\n## gradle\n\n**Step 1.** Add the JitPack repository to your build file\n\nAdd it in your root build.gradle at the end of repositories:\n\n```\n    allprojects {\n        repositories {\n            ...\n            maven { url \"https://jitpack.io\" }\n        }\n    }\n```\n\n**Step 2.** Add the dependency\n\n```\n    dependencies {\n            compile 'com.github.hss01248:NotifyUtil:1.0.1'\n    }\n```\n\n\n\n## 示例代码\n\n```\n NotifyUtil.buildSimple(100,R.mipmap.ic_launcher,\"标题标题标题图表题滴滴滴\",\"哈哈哈哈哈哈哈呼呼呼呼呼呼\",null)\n                        .setHeadup()\n                        .addBtn(R.mipmap.ic_launcher,\"left\", NotifyUtil.buildIntent(MainActivity.class))\n                        .addBtn(R.mipmap.ic_launcher,\"rightdd\", NotifyUtil.buildIntent(MainActivity.class))\n                        .show();\n        \nNotifyUtil.buildBigPic(101,R.drawable.timg,\"title\",\"content\",\"summmaujds\")\n                        .setPicRes(R.drawable.timg2)\n                        .show();\n                        \n NotifyUtil.buildProgress(102,R.mipmap.ic_launcher,\"正在下载\",progresses,3456,\"下载进度:%d%%\").show();\n \n NotifyUtil.buildMailBox(104,R.drawable.timg,\"title\")\n                        .addMsg(\"11111111111\")\n                        .addMsg(\"33333333333333\")\n                        .addMsg(\"6666666666666666666\")\n                        .show();\n\nNotifyUtil.buildBigText(103,R.drawable.timg,\"jtitle\",\"我学习最快的方法就是先看效果，\" +\n                        \"再想原理最后，将它实现。效果是最直观的，而且能够有效的判断所学的东西是不是想要的。\" +\n                        \"现在网上的资料实在太杂，很多花了很多时间去研究，最后发现坑爹了，不是想要的。\" +\n                        \"这篇文章首先会介绍能实现的主要功能。然后是解决问题的基本思想，接着是具体的一些实现。\" +\n                        \"本篇文章和以前的风格有所不同，以前都是文章中代码比较少，附上demo,但发现这样可能不方便读者，\" +\n                        \"所以采用了实现效果以及主要代码的形式。这种方式现在还在测试阶段，如果觉得以前的模式比较\" +\n                        \"好或者其他更好的方式的话可以給我留言，以后的文章会做出相应的调整 。\").show();\n```\n\n\n# todo\n* 参考[网易考拉 Android 通知栏适配全方案](https://www.jianshu.com/p/9bf70d125582)进行完善\n* 适配Android O\n* 增加权限判断\n","funding_links":[],"categories":["通知"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhss01248%2FNotifyUtil","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhss01248%2FNotifyUtil","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhss01248%2FNotifyUtil/lists"}