{"id":1480,"date":"2012-08-02T15:54:54","date_gmt":"2012-08-02T07:54:54","guid":{"rendered":"http:\/\/leybreeze.com\/blog\/?p=1480"},"modified":"2012-08-02T15:54:54","modified_gmt":"2012-08-02T07:54:54","slug":"android%e4%b8%ad%e5%9c%a8%e9%80%9a%e7%9f%a5%e6%a0%8f%e5%86%85%e5%b8%b8%e9%a9%bb%e5%ba%94%e7%94%a8%e7%a8%8b%e5%ba%8f%e6%b6%88%e6%81%af","status":"publish","type":"post","link":"http:\/\/leybreeze.com\/blog\/?p=1480","title":{"rendered":"Android\u4e2d\u5728\u901a\u77e5\u680f\u5185\u5e38\u9a7b\u5e94\u7528\u7a0b\u5e8f\u6d88\u606f"},"content":{"rendered":"<p>\u4ee3\u7801\u4e0e\u8303\u4f8b\uff1a<\/p>\n<pre lang=\"JAVA\">\r\n\/\/ \u6dfb\u52a0\u5e38\u9a7b\u901a\u77e5\r\nprivate void setNotification() {\r\n    NotificationManager notificationManager = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);\r\n    Notification notification = new Notification(R.drawable.icon, getString(R.string.app_name), System.currentTimeMillis());\r\n    Intent intent = new Intent(this, Sample.class);\r\n    notification.flags = Notification.FLAG_ONGOING_EVENT; \/\/ \u8bbe\u7f6e\u5e38\u9a7b Flag\r\n    PendingIntent contextIntent = PendingIntent.getActivity(this, 0, intent, 0);\r\n    notification.setLatestEventInfo(getApplicationContext(), getString(R.string.app_name), getString(R.string.information), contextIntent);\r\n    notificationManager.notify(R.string.app_name, notification);\r\n}\r\n\r\n\/\/ \u53d6\u6d88\u901a\u77e5\r\nprivate void cancelNotification() {\r\n    NotificationManager notificationManager = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);\r\n    notificationManager.cancel(R.string.app_name);\r\n}\r\n<\/pre>\n<p>\u8bf4\u660e\uff1a\u901a\u8fc7 setNotification()  \u53ef\u4ee5\u5728\u901a\u77e5\u680f\u4e2d\u6dfb\u52a0\u4e00\u6761\u5e38\u9a7b\u901a\u77e5\uff0c\u901a\u8fc7 cancelNotification() \u53d6\u6d88\u8be5\u901a\u77e5\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4ee3\u7801\u4e0e\u8303\u4f8b\uff1a \/\/ \u6dfb\u52a0\u5e38\u9a7b\u901a\u77e5 private void setNotification() { Notif &hellip; <a href=\"http:\/\/leybreeze.com\/blog\/?p=1480\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">\u201cAndroid\u4e2d\u5728\u901a\u77e5\u680f\u5185\u5e38\u9a7b\u5e94\u7528\u7a0b\u5e8f\u6d88\u606f\u201d<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[101,19,17,57],"_links":{"self":[{"href":"http:\/\/leybreeze.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1480"}],"collection":[{"href":"http:\/\/leybreeze.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/leybreeze.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/leybreeze.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/leybreeze.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1480"}],"version-history":[{"count":1,"href":"http:\/\/leybreeze.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1480\/revisions"}],"predecessor-version":[{"id":1481,"href":"http:\/\/leybreeze.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1480\/revisions\/1481"}],"wp:attachment":[{"href":"http:\/\/leybreeze.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1480"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/leybreeze.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1480"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/leybreeze.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1480"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}