

{"id":1039,"date":"2017-05-09T12:00:22","date_gmt":"2017-05-09T03:00:22","guid":{"rendered":"https:\/\/curecode.jp\/tech\/?p=1039"},"modified":"2017-05-02T12:00:36","modified_gmt":"2017-05-02T03:00:36","slug":"android-alarmmanager-not-raise-onreceive","status":"publish","type":"post","link":"https:\/\/curecode.jp\/tech\/android-alarmmanager-not-raise-onreceive\/","title":{"rendered":"Android \u306e AlarmManager \u3067 onReceive \u304c\u547c\u3070\u308c\u306a\u3044"},"content":{"rendered":"<p>\n  Android \u306e AlarmManager \u3067\u306e\u51e6\u7406\u3092\u5b9f\u88c5\u3057\u3066\u3044\u305f\u3068\u304d\u306b\u30cf\u30de\u3063\u305f\u306e\u3067\u6ce8\u610f\u70b9\u3092\u66f8\u3044\u3066\u304a\u304d\u307e\u3059\u3002\n<\/p>\n<h3>\u7570\u306a\u308b\u6642\u9593\u306b\u5b9f\u884c\u3059\u308b\u8907\u6570\u306e\u30a2\u30e9\u30fc\u30e0\u3092\u540c\u6642\u306b\u30bb\u30c3\u30c8\u3059\u308b<\/h3>\n<p>\n  \u4eca\u56de\u306f\u5b9a\u671f\u7684\u3067\u306f\u306a\u304f\u3001\u3044\u304f\u3064\u304b\u306e\u6642\u523b\u3067\u5c11\u3057\u305a\u3064\u7570\u306a\u308b\u51e6\u7406\u3092\u3055\u305b\u305f\u304b\u3063\u305f\u306e\u3067\u3059\u304c\u3001\u305d\u308c\u3092\u4e00\u5ea6\u306b\u30bb\u30c3\u30c8\u3057\u3088\u3046\u3068\u8003\u3048\u3066\u3044\u307e\u3057\u305f\u3002\u5185\u5bb9\u304c\u7570\u306a\u308b Intent \u3092\u305d\u308c\u305e\u308c\u30bb\u30c3\u30c8\u3057\u305f pendingIntent \u3092\u8907\u6570 AlarmManager \u306b\u9001\u308b\u3068\u3044\u3046\u3053\u3068\u3092\u3057\u3066\u3044\u307e\u3057\u305f\u3002\n<\/p>\n<p>\n  \u3057\u304b\u3057\u3001\u6307\u5b9a\u3057\u305f\u6642\u9593\u304c\u6765\u3066\u3082 BroadcastReceiver \u306e onReceive \u304c\u547c\u3070\u308c\u307e\u305b\u3093\u3002\u5358\u4f53\u306e\u30a2\u30e9\u30fc\u30e0\u3060\u3068\u547c\u3070\u308c\u307e\u3059\u304c\u3001\u8907\u6570\u306b\u3059\u308b\u3068\u547c\u3070\u308c\u307e\u305b\u3093\u3002\n<\/p>\n<h3>AlarmManager \u306e\u72b6\u614b\u3092\u78ba\u8a8d\u3059\u308b\u3068\u8907\u6570\u306e\u30a2\u30e9\u30fc\u30e0\u304c\u30bb\u30c3\u30c8\u3055\u308c\u3066\u898b\u3048\u308b<\/h3>\n<p>\n  AlarmManager \u306e\u72b6\u614b\u3092\u53d6\u5f97\u3059\u308b\u306b\u306f\u3001\u958b\u767a\u74b0\u5883\u304b\u3089\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u307e\u3059\u3002\n<\/p>\n<pre><code class=\"shell\">\r\nadb shell dumpsys alarm > alarm.txt\r\n<\/code><\/pre>\n<p>\n  \u30a2\u30e9\u30fc\u30e0\u30de\u30cd\u30fc\u30b8\u30e3\u30fc\u306e\u72b6\u614b\u304c\u30c0\u30f3\u30d7\u3055\u308c\u305f alarm.txt \u3092\u78ba\u8a8d\u3059\u308b\u3068\u3001\u8907\u6570\u306e\u30a2\u30e9\u30fc\u30e0\u304c\u30bb\u30c3\u30c8\u3055\u308c\u3066\u3044\u308b\u3088\u3046\u306b\u898b\u3048\u307e\u3059\u3002\n<\/p>\n<p>\n  \u3057\u304b\u3057\u3001\u3042\u3068\u3067\u308f\u304b\u3063\u305f\u3053\u3068\u3067\u3059\u304c\u3001\u5b9f\u969b\u306b\u306f\u6700\u5f8c\u306e\u30a2\u30e9\u30fc\u30e0\u3060\u3051\u304c\u6709\u52b9\u306b\u306a\u3063\u3066\u3044\u307e\u3057\u305f\u3002\n<\/p>\n<p>\n  \u539f\u56e0\u306f\u5358\u7d14\u306a\u3053\u3068\u3067\u3059\u304c\u3001Intent \u3092 PendungIntent \u306b\u6e21\u3059\u3068\u304d\u306b\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u3057\u3066\u7b2c4\u5f15\u6570\u306b <code>PendingIntent.FLAG_CANCEL_CURRENT<\/code> \u3092\u6307\u5b9a\u3057\u3066\u3044\u307e\u3057\u305f\u3002\n<\/p>\n<pre><code class=\"java\">\r\n\/\/intent \u3092 PendingIntent \u306b\u30bb\u30c3\u30c8\r\nPendingIntent sender = PendingIntent.getBroadcast(getApplicationContext(), 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);\r\n\/\/\u30a2\u30e9\u30fc\u30e0\u30de\u30cd\u30fc\u30b8\u30e3\u30fc\u306e\u53d6\u5f97\r\nAlarmManager alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);\r\n\/\/\u30a2\u30e9\u30fc\u30e0\u30de\u30cd\u30fc\u30b8\u30e3\u30fc\u306b\u30bb\u30c3\u30c8\r\nalarmManager.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), sender);\r\n<\/code><\/pre>\n<p>\n  \u3053\u306e\u72b6\u614b\u3060\u3068\u3001\u6b21\u306e PendingIntent \u304c AlarmManager \u306b\u6e21\u3055\u308c\u305f\u3068\u304d\u306b\u3001\u524d\u3082\u306e\u3068\u540c\u4e00\u3060\u3068\u5224\u65ad\u3055\u308c\u3066\u30ad\u30e3\u30f3\u30bb\u30eb\u3055\u308c\u3066\u3044\u307e\u3057\u305f\u3002\u305d\u306e\u305f\u3081\u3001\u4e00\u756a\u6700\u5f8c\u306b\u8ffd\u52a0\u3057\u305f\uff08\u304b\u306a\u308a\u6642\u9593\u304c\u5148\u306e\uff09\u4e88\u5b9a\u3060\u3051\u304c\u6709\u52b9\u306b\u306a\u3063\u305f\u72b6\u614b\u306b\u306a\u3063\u3066\u3044\u305f\u3088\u3046\u3067\u3059\u3002\u3057\u304b\u3057\u3001<strong>\u30ad\u30e3\u30f3\u30bb\u30eb\u3055\u308c\u3066\u3044\u308b\u306b\u3082\u304b\u304b\u308f\u3089\u305a AlarmManager \u306e\u72b6\u614b\u30c0\u30f3\u30d7\u3067\u306f\u3059\u3079\u3066\u5b9f\u884c\u3055\u308c\u3066\u3044\u308b\u3088\u3046\u898b\u3048\u3066\u3057\u307e\u3044\u307e\u3059<\/strong>\uff08\u3053\u3053\u3067\u30cf\u30de\u308a\u307e\u3057\u305f\uff09\u2026\u2026\u3002\n<\/p>\n<p>\n  \u7b2c4\u5f15\u6570\u306b <code>PendingIntent.FLAG_UPDATE_CURRENT<\/code> \u3092\u6307\u5b9a\u3057\u3066\u307f\u308b\u3068\u30011\u3064\u3060\u3051\u6709\u52b9\u306b\u306a\u308a\u307e\u3057\u305f\u3002\u3057\u304b\u3057\u8907\u6570\u3092\u4e8b\u524d\u306b\u30bb\u30c3\u30c8\u3057\u3066\u3057\u307e\u3046\u3068\u3001\u4e0a\u66f8\u304d\u3055\u308c\u3066\u3044\u304f\u306e\u3067\u3001\u6700\u5f8c\u306e\u3082\u306e\u3060\u3051\u304c\u6b8b\u308b\u611f\u3058\u3067\u3059\u3002\u3053\u308c\u306f\u3053\u308c\u3067\u4fbf\u5229\u306a\u306e\u3067\u3059\u304c\u3002\n<\/p>\n<h3>\u89e3\u6c7a\u7b56<\/h3>\n<p>\n  \u8907\u6570\u306e\u4e88\u5b9a\u3092 AlarmManager \u306b\u767b\u9332\u3059\u308b\u3053\u3068\u306f\u3042\u304d\u3089\u3081\u3066\u3001\u76f4\u8fd1\u3067\u547c\u3073\u51fa\u3057\u305f\u3044\u3082\u306e1\u3064\u3060\u3051\u3092\u767b\u9332\u3057\u307e\u3057\u305f\u3002\u7b2c4\u5f15\u6570\u306b\u306f <code>PendingIntent.FLAG_ONE_SHOT<\/code> \u3092\u6307\u5b9a\u3057\u3066\u547c\u3073\u51fa\u3057\u307e\u3057\u305f\u3002\u305d\u3057\u3066\u30ec\u30b7\u30fc\u30d0\u30fc\u306e onReceive \u3067\u5fc5\u8981\u306a\u51e6\u7406\u3092\u3057\u305f\u3042\u3068\u3001\u6539\u3081\u3066\u6b21\u306e\u30a2\u30e9\u30fc\u30e0\u3092\u30bb\u30c3\u30c8\u3059\u308b\u3088\u3046\u306b\u3057\u307e\u3057\u305f\u3002\n<\/p>\n<p>\n  \u4eca\u56de\u306f\u5358\u7d14\u306a\u7e70\u308a\u8fd4\u3057\u30a2\u30e9\u30fc\u30e0\u3067\u306f\u306a\u3044\u306e\u3067\u3001\u3053\u3061\u3089\u306e\u65b9\u304c\u67d4\u8edf\u306b\u5bfe\u5fdc\u3067\u304d\u307e\u3057\u305f\u3002Intent \u306e\u4f7f\u3063\u3066\u3044\u306a\u3044\u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u30bb\u30c3\u30c8\u3057\u3066\u5225\u306e\u30a2\u30e9\u30fc\u30e0\u3068\u3057\u3066\u8a8d\u8b58\u3055\u305b\u308b\u65b9\u6cd5\u3082\u3042\u308a\u307e\u3059\u304c\u3001Android \u306e\u30a2\u30e9\u30fc\u30e0\u306f\u6642\u9593\u304c\u305a\u308c\u308b\u3053\u3068\u304c\u3042\u308a\u3001\u5b9a\u671f\u7684\u306b\u30bb\u30c3\u30c8\u3057\u76f4\u3055\u306a\u3044\u3068\u3044\u3051\u306a\u3044\u3068\u3044\u3046\u7406\u7531\u3082\u3042\u308a\u3001\u4eca\u56de\u306f1\u4ef6\u305a\u3064\u767b\u9332\u3059\u308b\u3088\u3046\u306b\u3057\u307e\u3057\u305f\u3002\n<\/p>\n<h3>\u53c2\u8003\u30b5\u30a4\u30c8<\/h3>\n<ul class=\"links\">\n<li><a href=\"http:\/\/workpiles.com\/2014\/06\/android-pendingintent-flag\/\"  target=\"_blank\">PendingIntent\u306e\u30d5\u30e9\u30b0\u8a2d\u5b9a\u306b\u3088\u308b\u632f\u308b\u821e\u3044\u306e\u9055\u3044 | Workpiles<\/a> \u3053\u3053\u306e\u89e3\u8aac\u304c\u308f\u304b\u308a\u3084\u3059\u304b\u3063\u305f\u3067\u3059\u3002<\/li>\n<li><a href=\"http:\/\/y-anz-m.blogspot.jp\/2011\/07\/androidappwidget-pendingintent-putextra.html\"  target=\"_blank\">Y.A.M \u306e \u96d1\u8a18\u5e33: Android\u3000AppWidget \u306e PendingIntent \u3067 putExtra \u3059\u308b\u3068\u304d\u306e\u6ce8\u610f<\/a> \u3053\u3053\u306b\u3088\u308b\u3068\u7b2c\uff12\u5f15\u6570\u3092 0 \u3067\u306f\u306a\u304f\u3066\u7570\u306a\u308b\u5024\u306b\u3059\u308c\u3070\u5225\u306e intent \u3068\u8a8d\u8b58\u3057\u3066\u304f\u308c\u305d\u3046\u3067\u3059\u304c\u3001\u4eca\u56de\u306f\u3046\u307e\u304f\u3044\u304d\u307e\u305b\u3093\u3067\u3057\u305f\u3002<\/li>\n<li><a href=\"http:\/\/labs.techfirm.co.jp\/android\/m_yamada\/1844\"  target=\"_blank\">AlarmManager\u306b\u7570\u306a\u308bintent\u3068\u8a8d\u8b58\u3055\u305b\u308b\u65b9\u6cd5 | Android Techfirm Lab<\/a>\u7570\u306a\u308b\u30c0\u30df\u30fc\u306e\u30d1\u30e9\u30e1\u30fc\u30bf\u30fc\u3092\u30bb\u30c3\u30c8\u3057\u3066\u6642\u9593\u5dee\u3067\u8907\u6570\u306e\u30a2\u30e9\u30fc\u30e0\u3092\u4f7f\u3046\u65b9\u6cd5\u304c\u66f8\u304b\u308c\u3066\u3044\u307e\u3059\u3002\u4eca\u56de\u306f\u8a66\u3057\u3066\u3044\u307e\u305b\u3093\u304c\u3053\u306e\u65b9\u6cd5\u3082\u4f7f\u3048\u308b\u3068\u601d\u3044\u307e\u3059\u3002<\/li>\n<\/ul>\n<h3>IT\u30a8\u30f3\u30b8\u30cb\u30a2\u52df\u96c6\u4e2d\uff01<\/h3>\n<p>\u30ad\u30e5\u30a2\u30b3\u30fc\u30c9\u682a\u5f0f\u4f1a\u793e\u306fIT\u30a8\u30f3\u30b8\u30cb\u30a2\u3092\u52df\u96c6\u3057\u3066\u304a\u308a\u307e\u3059\u3002\u5c11\u4eba\u6570\u306e\u8077\u5834\u306a\u306e\u3067\u3001\u4e0a\u6d41\u30fb\u4e0b\u6d41\u3084\u30b5\u30fc\u30d0\u30fc\u30fb\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u5bfe\u5fdc\u306e\u57a3\u6839\u306a\u304f\u3001\u3042\u306a\u305f\u306e\u5f37\u307f\u3092\u6d3b\u304b\u3057\u306a\u304c\u3089 \u3044\u308d\u3044\u308d\u306a\u3053\u3068\u306b\u30c1\u30e3\u30ec\u30f3\u30b8\u53ef\u80fd\u3067\u3059\u3002\u30a8\u30f3\u30b8\u30cb\u30a2\u3068\u3057\u3066\u306e\u672a\u7d4c\u9a13\u306e\u65b9\u3001\u7d4c\u9a13\u304c\u5c11\u306a\u3044\u65b9\u3082\u6b53\u8fce\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u4e0b\u8a18\u3088\u308aIT\u30a8\u30f3\u30b8\u30cb\u30a2\u52df\u96c6\u306e\u63a1\u7528\u60c5\u5831\u3092\u3054\u89a7\u3044\u305f\u3060\u3051\u307e\u3059\u3002<\/p>\n<div class=\"curecode_recruit_bn\">\n\t\t\t\t<a href=\"https:\/\/curecode.jp\/recruit\/itengineer\/\" target=\"_blank\" rel=\"noopener noreferrer\"><br \/>\n\t\t\t\t\t\t<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/curecode.jp\/tech\/wp-content\/themes\/tech\/images\/it_recruit.png?20241220\" alt=\"\u4e8b\u696d\u62e1\u5927\u306b\u4f34\u3044\u65b0\u3057\u3044\u9818\u57df\u306b\u4e00\u7dd2\u306b\u53d6\u308a\u7d44\u3093\u3067\u3044\u304f\u30e1\u30f3\u30d0\u30fc\u3092\u52df\u96c6\u3057\u307e\u3059\u3002\"  width=\"500\" height=\"180\"\/><br \/>\n\t\t\t\t<\/a>\n\t\t<\/div>\n<h3>\u30ad\u30e5\u30a2\u30b3\u30fc\u30c9\u516c\u5f0f\u30a4\u30f3\u30b9\u30bf\u30b0\u30e9\u30e0<\/h3>\n<p>\u30ad\u30e5\u30a2\u30b3\u30fc\u30c9\u682a\u5f0f\u4f1a\u793e\u306e\u65b0\u30b5\u30fc\u30d3\u30b9\u60c5\u5831\u3084\u3001\u30aa\u30d5\u30a3\u30b9\u30e9\u30a4\u30d5\u306e\u7d20\u6575\u306a\u77ac\u9593\u307e\u3067\u3002\u79c1\u305f\u3061\u306e\u65e5\u3005\u306e\u55b6\u307f\u3092\u3054\u7d39\u4ecb\u3057\u307e\u3059\u3002<\/p>\n<div class=\"curecode_recruit_bn\">\n\t\t\t\t<a href=\"https:\/\/www.instagram.com\/curecode\/\" target=\"_blank\" rel=\"noopener noreferrer\"><br \/>\n\t\t\t\t\t\t<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/curecode.jp\/tech\/wp-content\/themes\/tech\/images\/insta_bn.png?20241220\" alt=\"\u4e8b\u696d\u62e1\u5927\u306b\u4f34\u3044\u65b0\u3057\u3044\u9818\u57df\u306b\u4e00\u7dd2\u306b\u53d6\u308a\u7d44\u3093\u3067\u3044\u304f\u30e1\u30f3\u30d0\u30fc\u3092\u52df\u96c6\u3057\u307e\u3059\u3002\"  width=\"500\" height=\"180\"\/><br \/>\n\t\t\t\t<\/a>\n\t\t<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Android \u306e AlarmManager \u3067\u306e\u51e6\u7406\u3092\u5b9f\u88c5\u3057\u3066\u3044\u305f\u3068\u304d\u306b\u30cf\u30de\u3063\u305f\u306e\u3067\u6ce8\u610f\u70b9\u3092\u66f8\u3044\u3066 [&hellip;]<\/p>\n","protected":false},"author":8,"featured_media":283,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[127,55],"tags":[128,129],"class_list":["post-1039","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-android","category-java","tag-alarmmanager","tag-pendingintent"],"_links":{"self":[{"href":"https:\/\/curecode.jp\/tech\/wp-json\/wp\/v2\/posts\/1039","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/curecode.jp\/tech\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/curecode.jp\/tech\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/curecode.jp\/tech\/wp-json\/wp\/v2\/users\/8"}],"replies":[{"embeddable":true,"href":"https:\/\/curecode.jp\/tech\/wp-json\/wp\/v2\/comments?post=1039"}],"version-history":[{"count":11,"href":"https:\/\/curecode.jp\/tech\/wp-json\/wp\/v2\/posts\/1039\/revisions"}],"predecessor-version":[{"id":1054,"href":"https:\/\/curecode.jp\/tech\/wp-json\/wp\/v2\/posts\/1039\/revisions\/1054"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/curecode.jp\/tech\/wp-json\/wp\/v2\/media\/283"}],"wp:attachment":[{"href":"https:\/\/curecode.jp\/tech\/wp-json\/wp\/v2\/media?parent=1039"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/curecode.jp\/tech\/wp-json\/wp\/v2\/categories?post=1039"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/curecode.jp\/tech\/wp-json\/wp\/v2\/tags?post=1039"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}